JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>2010, tatu: and obviously we also must pass 'this', * to create actual linking. */ if (jf == null) { _jsonFactory = new MappingJsonFactory(this); } else { _jsonFactory = jf; if (jf.getCodec() == null) { // as per [JACKSON-741] _jsonFactory.setCodec(this); } } _subtypeResolver = new StdSubtypeResolver(); RootNameLookup rootNames = new RootNameLookup(); // and default type factory is shared one _typeFactory = TypeFactory.defaultInstance(); SimpleMixInResolver mixins = new SimpleMixInResolver(null); _mixIns = mixins; BaseSettings base = DEFAULT_BASE.withClassIntrospector(defaultClassIntrospector()); _serializationConfig = new SerializationConfig(base, _subtypeResolver, mixins, rootNames); _deserializationConfig = new DeserializationConfig(base, _subtypeResolver, mixins, rootNames); // Some overrides we may need final boolean needOrder = _jsonFactory.requiresPropertyOrdering(); if (needOrder ^ _serializationConfig.isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)) { configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, needOrder); } _serializerProvider = (sp == null) ? new DefaultSerializerProvider.Impl() : sp; _deserializationContext = (dc == null) ? new DefaultDeserializationContext.Impl(BeanDeserializerFactory.instance) : dc; // Default serializer factory is stateless, can just assign _serializerFactory = BeanSerializerFactory.instance; } /** * Overridable helper method used to construct default {@link ClassIntrospector} * to use. * * @since 2.5 */ protected ClassIntrospector defaultClassIntrospector() { return new BasicClassIntrospector(); } /* /********************************************************** /* Methods sub-classes MUST override /********************************************************** */ /** * Method for creating a new {@link ObjectMapper} instance that * has same initial configuration as this instance. Note that this * also requires making a copy of the underlying {@link JsonFactory} * instance. *<p> * Method is typically *

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> produce {@link ObjectWriter} * instances of proper sub-type * * @since 2.5 */ protected ObjectWriter _newWriter(SerializationConfig config, JavaType rootType, PrettyPrinter pp) { return new ObjectWriter(this, config, rootType, pp); } /* /********************************************************** /* Versioned impl /********************************************************** */ /** * Method that will return version information stored in and read from jar * that contains this class. */ @Override public Version version() { return com.fasterxml.jackson.databind.cfg.PackageVersion.VERSION; } /* /********************************************************** /* Module registration, discovery /********************************************************** */ /** * Method for registering a module that can extend functionality * provided by this mapper; for example, by adding providers for * custom serializers and deserializers. * * @param module Module to register */ public ObjectMapper registerModule(Module module) { if (isEnabled(MapperFeature.IGNORE_DUPLICATE_MODULE_REGISTRATIONS)) { Object typeId = module.getTypeId(); if (typeId != null) { if (_registeredModuleTypes == null) { // plus let's keep them in order too, easier to debug or expose // in registration order if that matter _registeredModuleTypes = new LinkedHashSet<Object>(); } // try adding; if already had it, should skip if (!_registeredModuleTypes.add(typeId)) { return this; } } } /* Let's ensure we have access to name and version information, * even if we do not have immediate use for either. This way we know * that they will be available from beginning */ String name = module.getModuleName(); if (name == null) { throw new IllegalArgumentException("Module without defined name"); } Version version = module.version(); if (version == null) { throw new IllegalArgumentException("Module without defined version"); } final ObjectMapper mapper = this; // And then call registration module.setupModule(new Module.SetupContext() { // // // Accessors @Override public Version getMapperVersion() { return version(); } @SuppressWarnings("unchecked") @Override public <C extends ObjectCodec> C getOwner() { // why do we

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> need the cast here?!? return (C) mapper; } @Override public TypeFactory getTypeFactory() { return _typeFactory; } @Override public boolean isEnabled(MapperFeature f) { return mapper.isEnabled(f); } @Override public boolean isEnabled(DeserializationFeature f) { return mapper.isEnabled(f); } @Override public boolean isEnabled(SerializationFeature f) { return mapper.isEnabled(f); } @Override public boolean isEnabled(JsonFactory.Feature f) { return mapper.isEnabled(f); } @Override public boolean isEnabled(JsonParser.Feature f) { return mapper.isEnabled(f); } @Override public boolean isEnabled(JsonGenerator.Feature f) { return mapper.isEnabled(f); } // // // Methods for registering handlers: deserializers @Override public void addDeserializers(Deserializers d) { DeserializerFactory df = mapper._deserializationContext._factory.withAdditionalDeserializers(d); mapper._deserializationContext = mapper._deserializationContext.with(df); } @Override public void addKeyDeserializers(KeyDeserializers d) { DeserializerFactory df = mapper._deserializationContext._factory.withAdditionalKeyDeserializers(d); mapper._deserializationContext = mapper._deserializationContext.with(df); } @Override public void addBeanDeserializerModifier(BeanDeserializerModifier modifier) { DeserializerFactory df = mapper._deserializationContext._factory.withDeserializerModifier(modifier); mapper._deserializationContext = mapper._deserializationContext.with(df); } // // // Methods for registering handlers: serializers @Override public void addSerializers(Serializers s) { mapper._serializerFactory = mapper._serializerFactory.withAdditionalSerializers(s); } @Override public void addKeySerializers(Serializers s) { mapper._serializerFactory = mapper._serializerFactory.withAdditionalKeySerializers(s); } @Override public void addBeanSerializerModifier(BeanSerializerModifier modifier) { mapper._serializerFactory = mapper._serializerFactory.withSerializerModifier(modifier); } // // // Methods for registering handlers: other @Override public void addAbstractTypeResolver(AbstractTypeResolver resolver) {

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>(dateFormat); _serializationConfig = _serializationConfig.with(dateFormat); return this; } /** * @since 2.5 */ public DateFormat getDateFormat() { // arbitrary choice but let's do: return _serializationConfig.getDateFormat(); } /** * Method for configuring {@link HandlerInstantiator} to use for creating * instances of handlers (such as serializers, deserializers, type and type * id resolvers), given a class. * * @param hi Instantiator to use; if null, use the default implementation */ public Object setHandlerInstantiator(HandlerInstantiator hi) { _deserializationConfig = _deserializationConfig.with(hi); _serializationConfig = _serializationConfig.with(hi); return this; } /** * Method for configuring {@link InjectableValues} which used to find * values to inject. */ public ObjectMapper setInjectableValues(InjectableValues injectableValues) { _injectableValues = injectableValues; return this; } /** * @since 2.6 */ public InjectableValues getInjectableValues() { return _injectableValues; } /** * Method for overriding default locale to use for formatting. * Default value used is {@link Locale#getDefault()}. */ public ObjectMapper setLocale(Locale l) { _deserializationConfig = _deserializationConfig.with(l); _serializationConfig = _serializationConfig.with(l); return this; } /** * Method for overriding default TimeZone to use for formatting. * Default value used is UTC (NOT local timezone). */ public ObjectMapper setTimeZone(TimeZone tz) { _deserializationConfig = _deserializationConfig.with(tz); _serializationConfig = _serializationConfig.with(tz); return this; } /* /********************************************************** /* Configuration, simple features: MapperFeature /********************************************************** */ /** * Method for checking whether given {@link MapperFeature} is enabled. */ public boolean isEnabled(MapperFeature f) { // ok to use either one, should be kept in sync return _serializationConfig.isEnabled(f); } /** * Method for changing state of an on/off mapper feature for * this mapper instance. */ public ObjectMapper

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> configure(MapperFeature f, boolean state) { _serializationConfig = state ? _serializationConfig.with(f) : _serializationConfig.without(f); _deserializationConfig = state ? _deserializationConfig.with(f) : _deserializationConfig.without(f); return this; } /** * Method for enabling specified {@link MapperConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper enable(MapperFeature... f) { _deserializationConfig = _deserializationConfig.with(f); _serializationConfig = _serializationConfig.with(f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper disable(MapperFeature... f) { _deserializationConfig = _deserializationConfig.without(f); _serializationConfig = _serializationConfig.without(f); return this; } /* /********************************************************** /* Configuration, simple features: SerializationFeature /********************************************************** */ /** * Method for checking whether given serialization-specific * feature is enabled. */ public boolean isEnabled(SerializationFeature f) { return _serializationConfig.isEnabled(f); } /** * Method for changing state of an on/off serialization feature for * this object mapper. */ public ObjectMapper configure(SerializationFeature f, boolean state) { _serializationConfig = state ? _serializationConfig.with(f) : _serializationConfig.without(f); return this; } /** * Method for enabling specified {@link DeserializationConfig} feature. * Modifies and returns this instance; no new object is created. */ public ObjectMapper enable(SerializationFeature f) { _serializationConfig = _serializationConfig.with(f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper enable(SerializationFeature first, SerializationFeature... f) { _serializationConfig = _serializationConfig.with(first, f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> returns this instance; no new object is created. */ public ObjectMapper disable(SerializationFeature f) { _serializationConfig = _serializationConfig.without(f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper disable(SerializationFeature first, SerializationFeature... f) { _serializationConfig = _serializationConfig.without(first, f); return this; } /* /********************************************************** /* Configuration, simple features: DeserializationFeature /********************************************************** */ /** * Method for checking whether given deserialization-specific * feature is enabled. */ public boolean isEnabled(DeserializationFeature f) { return _deserializationConfig.isEnabled(f); } /** * Method for changing state of an on/off deserialization feature for * this object mapper. */ public ObjectMapper configure(DeserializationFeature f, boolean state) { _deserializationConfig = state ? _deserializationConfig.with(f) : _deserializationConfig.without(f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper enable(DeserializationFeature feature) { _deserializationConfig = _deserializationConfig.with(feature); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper enable(DeserializationFeature first, DeserializationFeature... f) { _deserializationConfig = _deserializationConfig.with(first, f); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper disable(DeserializationFeature feature) { _deserializationConfig = _deserializationConfig.without(feature); return this; } /** * Method for enabling specified {@link DeserializationConfig} features. * Modifies and returns this instance; no new object is created. */ public ObjectMapper disable(DeserializationFeature first, DeserializationFeature... f) { _deserializationConfig = _de

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>serializationConfig.without(first, f); return this; } /* /********************************************************** /* Configuration, simple features: JsonParser.Feature /********************************************************** */ public boolean isEnabled(JsonParser.Feature f) { return _deserializationConfig.isEnabled(f, _jsonFactory); } /** * Method for changing state of specified {@link com.fasterxml.jackson.core.JsonParser.Feature}s * for parser instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method * on {@link #getFactory}. */ public ObjectMapper configure(JsonParser.Feature f, boolean state) { _jsonFactory.configure(f, state); return this; } /** * Method for enabling specified {@link com.fasterxml.jackson.core.JsonParser.Feature}s * for parser instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method on {@link #getFactory}. * * @since 2.5 */ public ObjectMapper enable(JsonParser.Feature... features) { for (JsonParser.Feature f : features) { _jsonFactory.enable(f); } return this; } /** * Method for disabling specified {@link com.fasterxml.jackson.core.JsonParser.Feature}s * for parser instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method on {@link #getFactory}. * * @since 2.5 */ public ObjectMapper disable(JsonParser.Feature... features) { for (JsonParser.Feature f : features) { _jsonFactory.disable(f); } return this; } /* /********************************************************** /* Configuration, simple features: JsonGenerator.Feature /********************************************************** */ public boolean isEnabled(JsonGenerator.Feature f) { return _serializationConfig.isEnabled(f, _jsonFactory); } /** * Method for changing state of an on/off {@link JsonGenerator} feature for * generator instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method * on {@link #getFactory}. */ public ObjectMapper configure(JsonGenerator.Feature f, boolean

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> state) { _jsonFactory.configure(f, state); return this; } /** * Method for enabling specified {@link com.fasterxml.jackson.core.JsonGenerator.Feature}s * for parser instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method on {@link #getFactory}. * * @since 2.5 */ public ObjectMapper enable(JsonGenerator.Feature... features) { for (JsonGenerator.Feature f : features) { _jsonFactory.enable(f); } return this; } /** * Method for disabling specified {@link com.fasterxml.jackson.core.JsonGenerator.Feature}s * for parser instances this object mapper creates. *<p> * Note that this is equivalent to directly calling same method on {@link #getFactory}. * * @since 2.5 */ public ObjectMapper disable(JsonGenerator.Feature... features) { for (JsonGenerator.Feature f : features) { _jsonFactory.disable(f); } return this; } /* /********************************************************** /* Configuration, simple features: JsonFactory.Feature /********************************************************** */ /** * Convenience method, equivalent to: *<pre> * getJsonFactory().isEnabled(f); *</pre> */ public boolean isEnabled(JsonFactory.Feature f) { return _jsonFactory.isEnabled(f); } /* /********************************************************** /* Public API (from ObjectCodec): deserialization /* (mapping from JSON to Java types); /* main methods /********************************************************** */ /** * Method to deserialize JSON content into a non-container * type (it can be an array type, however): typically a bean, array * or a wrapper type (like {@link java.lang.Boolean}). *<p> * Note: this method should NOT be used if the result type is a * container ({@link java.util.Collection} or {@link java.util.Map}. * The reason is that due to type erasure, key and value types * can not be introspected when using this method. * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> * @param source URL to use for fetching contents to parse as JSON for building a tree instance * * @return a {@link JsonNode}, if valid JSON content found; null * if input has no content to bind -- note, however, that if * JSON <code>null</code> token is found, it will be represented * as a non-null {@link JsonNode} (one that returns <code>true</code> * for {@link JsonNode#isNull()} * * @throws IOException if a low-level I/O problem (unexpected end-of-input, * network error) occurs (passed through as-is without additional wrapping -- note * that this is one case where {@link DeserializationFeature#WRAP_EXCEPTIONS} * does NOT result in wrapping of exception even if enabled) * @throws JsonParseException if underlying input contains invalid content * of type {@link JsonParser} supports (JSON for default case) */ public JsonNode readTree(URL source) throws IOException, JsonProcessingException { JsonNode n = (JsonNode) _readMapAndClose(_jsonFactory.createParser(source), JSON_NODE_TYPE); return (n == null) ? NullNode.instance : n; } /* /********************************************************** /* Public API (from ObjectCodec): serialization /* (mapping from Java types to Json) /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ @Override public void writeValue(JsonGenerator g, Object value) throws IOException, JsonGenerationException, JsonMappingException { SerializationConfig config = getSerializationConfig(); /* 12-May-2015/2.6, tatu: Looks like we do NOT want to call the usual * 'config.initialize(g)` here, since it is assumed that generator * has been configured by caller. But for some reason we don't * trust indentation settings... */ // 10-Aug-2012, tatu: as per [Issue#12], must handle indentation: if (config.isEnabled(SerializationFeature.INDENT_OUTPUT)) { if (g.getPrettyPrinter() == null) { g.setPrettyPrinter(

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>config.constructDefaultPrettyPrinter()); } } if (config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _writeCloseableValue(g, value, config); } else { _serializerProvider(config).serializeValue(g, value); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { g.flush(); } } } /* /********************************************************** /* Public API (from TreeCodec via ObjectCodec): Tree Model support /********************************************************** */ @Override public void writeTree(JsonGenerator jgen, TreeNode rootNode) throws IOException, JsonProcessingException { SerializationConfig config = getSerializationConfig(); _serializerProvider(config).serializeValue(jgen, rootNode); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } } /** * Method to serialize given JSON Tree, using generator * provided. */ public void writeTree(JsonGenerator jgen, JsonNode rootNode) throws IOException, JsonProcessingException { SerializationConfig config = getSerializationConfig(); _serializerProvider(config).serializeValue(jgen, rootNode); if (config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { jgen.flush(); } } /** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) */ @Override public ObjectNode createObjectNode() { return _deserializationConfig.getNodeFactory().objectNode(); } /** *<p> * Note: return type is co-variant, as basic ObjectCodec * abstraction can not refer to concrete node types (as it's * part of core package, whereas impls are part of mapper * package) */ @Override public ArrayNode createArrayNode() { return _deserializationConfig.getNodeFactory().arrayNode(); } /** * Method for constructing a {@link JsonParser} out of JSON tree * representation. * * @param n Root node of the tree that resulting parser will read from */ @Override

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>15-Mar-2013, tatu: Important! Indicate that static typing is needed: ((rootType == null) ? null : _typeFactory.constructType(rootType)), /*PrettyPrinter*/null); } /** * @deprecated Since 2.5, use {@link #writerFor(JavaType)} instead */ @Deprecated public ObjectWriter writerWithType(JavaType rootType) { return _newWriter(getSerializationConfig(), rootType, /*PrettyPrinter*/null); } /* /********************************************************** /* Extended Public API: constructing ObjectReaders /* for more advanced configuration /********************************************************** */ /** * Factory method for constructing {@link ObjectReader} with * default settings. Note that the resulting instance is NOT usable as is, * without defining expected value type. */ public ObjectReader reader() { return _newReader(getDeserializationConfig()).with(_injectableValues); } /** * Factory method for constructing {@link ObjectReader} with * specified feature enabled (compared to settings that this * mapper instance has). * Note that the resulting instance is NOT usable as is, * without defining expected value type. */ public ObjectReader reader(DeserializationFeature feature) { return _newReader(getDeserializationConfig().with(feature)); } /** * Factory method for constructing {@link ObjectReader} with * specified features enabled (compared to settings that this * mapper instance has). * Note that the resulting instance is NOT usable as is, * without defining expected value type. */ public ObjectReader reader(DeserializationFeature first, DeserializationFeature... other) { return _newReader(getDeserializationConfig().with(first, other)); } /** * Factory method for constructing {@link ObjectReader} that will * update given Object (usually Bean, but can be a Collection or Map * as well, but NOT an array) with JSON data. Deserialization occurs * normally except that the root-level value in JSON is not used for * instantiating a new object; instead give updateable object is used * as root. * Runtime type of value object is used for locating deserializer, * unless overridden by other factory methods of {@link ObjectReader} */ public ObjectReader readerForUpdating(Object valueToUpdate) { Java

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> visiting type hierarchy for given type, using specified visitor. * Visitation uses <code>Serializer</code> hierarchy and related properties *<p> * This method can be used for things like * generating <a href="http://json-schema.org/">JSON Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.1 */ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } _serializerProvider(getSerializationConfig()).acceptJsonFormatVisitor(type, visitor); } /* /********************************************************** /* Internal methods for serialization, overridable /********************************************************** */ /** * Overridable helper method used for constructing * {@link SerializerProvider} to use for serialization. */ protected DefaultSerializerProvider _serializerProvider(SerializationConfig config) { return _serializerProvider.createInstance(config, _serializerFactory); } /** * @deprecated Since 2.6, use {@link SerializationConfig#constructDefaultPrettyPrinter()} directly */ @Deprecated protected PrettyPrinter _defaultPrettyPrinter() { return _serializationConfig.constructDefaultPrettyPrinter(); } /** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator g, Object value) throws IOException { SerializationConfig cfg = getSerializationConfig(); cfg.initialize(g); // since 2.5 if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(g, value); closed = true; g.close(); } finally { /* won't try to close twice; also, must catch exception (so it * will not mask exception that is pending) */ if (!closed) { /* 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of * structures, which typically causes more damage.

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> */ g.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { g.close(); } catch (IOException ioe) { } } } } protected final void _configAndWriteValue(JsonGenerator g, Object value, Class<?> viewClass) throws IOException { SerializationConfig cfg = getSerializationConfig().withView(viewClass); cfg.initialize(g); // since 2.5 // [JACKSON-282]: consider Closeable if (cfg.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { _configAndWriteCloseable(g, value, cfg); return; } boolean closed = false; try { _serializerProvider(cfg).serializeValue(g, value); closed = true; g.close(); } finally { if (!closed) { // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. g.disable(JsonGenerator.Feature.AUTO_CLOSE_JSON_CONTENT); try { g.close(); } catch (IOException ioe) { } } } } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _configAndWriteCloseable(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException, JsonGenerationException, JsonMappingException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(g, value); JsonGenerator tmpGen = g; g = null; tmpGen.close(); Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { /* Need to close both generator and value, as long as they haven't yet * been closed */ if (g != null) { // 04-Mar-2014, tatu: But! Let's try to prevent auto-closing of // structures, which typically causes more damage. g.disable(JsonGenerator.Feature.AUTO_CLOSE_

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>JSON_CONTENT); try { g.close(); } catch (IOException ioe) { } } if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } } /** * Helper method used when value to serialize is {@link Closeable} and its <code>close()</code> * method is to be called right after serialization has been called */ private final void _writeCloseableValue(JsonGenerator g, Object value, SerializationConfig cfg) throws IOException, JsonGenerationException, JsonMappingException { Closeable toClose = (Closeable) value; try { _serializerProvider(cfg).serializeValue(g, value); if (cfg.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { g.flush(); } Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { if (toClose != null) { try { toClose.close(); } catch (IOException ioe) { } } } } /* /********************************************************** /* Internal methods for deserialization, overridable /********************************************************** */ /** * Internal helper method called to create an instance of {@link DeserializationContext} * for deserializing a single root value. * Can be overridden if a custom context is needed. */ protected DefaultDeserializationContext createDeserializationContext(JsonParser jp, DeserializationConfig cfg) { return _deserializationContext.createInstance(cfg, jp, _injectableValues); } /** * Actual implementation of value reading+binding operation. */ protected Object _readValue(DeserializationConfig cfg, JsonParser jp, JavaType valueType) throws IOException, JsonParseException, JsonMappingException { /* First: may need to read the next token, to initialize * state (either before first read from parser, or after * previous token has been cleared) */ Object result; JsonToken t = _initForReading(jp); if (t == JsonToken.VALUE_NULL) { // [JACKSON-643]: Ask JsonDeserializer what 'null value' to use: DeserializationContext ctxt = createDeserializationContext(jp, cfg); result = _findRootDeserializer

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> configuration /********************************************************** */ @Override public JsonGenerator enable(Feature f) { _generatorFeatures |= f.getMask(); return this; } @Override public JsonGenerator disable(Feature f) { _generatorFeatures &= ~f.getMask(); return this; } //public JsonGenerator configure(SerializationFeature f, boolean state) { } @Override public boolean isEnabled(Feature f) { return (_generatorFeatures & f.getMask()) != 0; } @Override public int getFeatureMask() { return _generatorFeatures; } @Override public JsonGenerator setFeatureMask(int mask) { _generatorFeatures = mask; return this; } @Override public JsonGenerator useDefaultPrettyPrinter() { // No-op: we don't indent return this; } @Override public JsonGenerator setCodec(ObjectCodec oc) { _objectCodec = oc; return this; } @Override public ObjectCodec getCodec() { return _objectCodec; } @Override public final JsonWriteContext getOutputContext() { return _writeContext; } /* /********************************************************** /* JsonGenerator implementation: capability introspection /********************************************************** */ /** * Since we can efficiently store <code>byte[]</code>, yes. */ @Override public boolean canWriteBinaryNatively() { return true; } /* /********************************************************** /* JsonGenerator implementation: low-level output handling /********************************************************** */ @Override public void flush() throws IOException { /* NOP */ } @Override public void close() throws IOException { _closed = true; } @Override public boolean isClosed() { return _closed; } /* /********************************************************** /* JsonGenerator implementation: write methods, structural /********************************************************** */ @Override public final void writeStartArray() throws IOException { _append(JsonToken.START_ARRAY); _writeContext = _writeContext.createChildArrayContext(); } @Override public final void writeEndArray() throws IOException { _append(JsonToken.END_ARRAY); // Let's allow unbalanced tho... i.e. not run out of root level, ever JsonWriteContext c = _writeContext.getParent

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> BaseContainer(@JsonProperty("baseContainerProperty") String bcp, @JsonProperty("base") Base b) { baseContainerProperty = bcp; base = b; } @JsonProperty public String getBaseContainerProperty() { return baseContainerProperty; } @JsonTypeInfo(use=JsonTypeInfo.Id.NAME, include=JsonTypeInfo.As.EXTERNAL_PROPERTY, property="type") @JsonProperty public Base getBase() { return base; } } interface Pet {} static class Dog implements Pet { public String name; } static class House831 { protected String petType; @JsonTypeInfo(use = Id.NAME, include = As.EXTERNAL_PROPERTY, property = "petType") @JsonSubTypes({@JsonSubTypes.Type(name = "dog", value = Dog.class)}) public Pet pet; public String getPetType() { return petType; } public void setPetType(String petType) { this.petType = petType; } } // for [databind#118] static class ExternalTypeWithNonPOJO { @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", visible = true, include = JsonTypeInfo.As.EXTERNAL_PROPERTY, defaultImpl = String.class) @JsonSubTypes({ @JsonSubTypes.Type(value = Date.class, name = "date"), @JsonSubTypes.Type(value = AsValueThingy.class, name = "thingy") }) public Object value; public ExternalTypeWithNonPOJO() { } public ExternalTypeWithNonPOJO(Object o) { value = o; } } // for [databind#119] static class AsValueThingy { public long rawDate; public AsValueThingy(long l) { rawDate = l; } public AsValueThingy() { } @JsonValue public Date serialization() { return new Date(rawDate); } } // [databind#222] static class Issue222Bean { @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", include = JsonTypeInfo.As.EXTERNAL_PROPERTY) public Issue222BeanB value;

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> public String type = "foo"; public Issue222Bean() { } public Issue222Bean(int v) { value = new Issue222BeanB(v); } } @JsonTypeName("222b") // shouldn't actually matter static class Issue222BeanB { public int x; public Issue222BeanB() { } public Issue222BeanB(int value) { x = value; } } // [databind#928] static class Envelope928 { Object _payload; public Envelope928(@JsonProperty("payload") @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.EXTERNAL_PROPERTY, property="class") Object payload) { _payload = payload; } } static class Payload928 { public String something; } /* /********************************************************** /* Unit tests, serialization /********************************************************** */ private final ObjectMapper MAPPER = new ObjectMapper(); public void testSimpleSerialization() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(ValueBean.class); // This may look odd, but one implementation nastiness is the fact // that we can not properly serialize type id before the object, // because call is made after property name (for object) has already // been written out. So we'll write it after... // Deserializer will work either way as it can not rely on ordering // anyway. assertEquals("{\"bean\":{\"value\":11},\"extType\":\"vbean\"}", mapper.writeValueAsString(new ExternalBean(11))); } // If trying to use with Class, should just become "PROPERTY" instead: public void testImproperExternalIdSerialization() throws Exception { ObjectMapper mapper = new ObjectMapper(); assertEquals("{\"extType\":\"funk\",\"i\":3}", mapper.writeValueAsString(new FunkyExternalBean())); } // for [databind#942] public void testExternalTypeIdWithNull() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(ValueBean.class); ExternalBean b; b = mapper.readValue(aposToQuotes("{'bean':null,'extType':'vbean'}"), ExternalBean

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>.class); assertNotNull(b); b = mapper.readValue(aposToQuotes("{'extType':'vbean','bean':null}"), ExternalBean.class); assertNotNull(b); } /* /********************************************************** /* Unit tests, deserialization /********************************************************** */ public void testSimpleDeserialization() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(ValueBean.class); ExternalBean result = mapper.readValue("{\"bean\":{\"value\":11},\"extType\":\"vbean\"}", ExternalBean.class); assertNotNull(result); assertNotNull(result.bean); ValueBean vb = (ValueBean) result.bean; assertEquals(11, vb.value); // let's also test with order switched: result = mapper.readValue("{\"extType\":\"vbean\", \"bean\":{\"value\":13}}", ExternalBean.class); assertNotNull(result); assertNotNull(result.bean); vb = (ValueBean) result.bean; assertEquals(13, vb.value); } // Test for verifying that it's ok to have multiple (say, 3) // externally typed things, mixed with other stuff... public void testMultipleTypeIdsDeserialization() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(ValueBean.class); String json = mapper.writeValueAsString(new ExternalBean3(3)); ExternalBean3 result = mapper.readValue(json, ExternalBean3.class); assertNotNull(result); assertNotNull(result.value1); assertNotNull(result.value2); assertNotNull(result.value3); assertEquals(3, ((ValueBean)result.value1).value); assertEquals(4, ((ValueBean)result.value2).value); assertEquals(5, ((ValueBean)result.value3).value); assertEquals(3, result.foo); } // Also, it should be ok to use @JsonCreator as well... public void testExternalTypeWithCreator() throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.registerSubtypes(ValueBean.class); String json = mapper.writeValueAsString(new ExternalBeanWithCreator(7)); ExternalBeanWithCreator result = mapper.readValue(json, ExternalBeanWithCreator.class); assertNotNull(result); assertNotNull(

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>result.value); assertEquals(7, ((ValueBean)result.value).value); assertEquals(7, result.foo); } // If trying to use with Class, should just become "PROPERTY" instead: public void testImproperExternalIdDeserialization() throws Exception { FunkyExternalBean result = MAPPER.readValue("{\"extType\":\"funk\",\"i\":3}", FunkyExternalBean.class); assertNotNull(result); assertEquals(3, result.i); result = MAPPER.readValue("{\"i\":4,\"extType\":\"funk\"}", FunkyExternalBean.class); assertNotNull(result); assertEquals(4, result.i); } public void testIssue798() throws Exception { Base base = new Derived1("derived1 prop val", "base prop val"); BaseContainer baseContainer = new BaseContainer("bc prop val", base); String generatedJson = MAPPER.writeValueAsString(baseContainer); BaseContainer baseContainer2 = MAPPER.readValue(generatedJson,BaseContainer.class); assertEquals("bc prop val", baseContainer.getBaseContainerProperty()); Base b = baseContainer2.getBase(); assertNotNull(b); if (b.getClass() != Derived1.class) { fail("Should have type Derived1, was "+b.getClass().getName()); } Derived1 derived1 = (Derived1) b; assertEquals("base prop val", derived1.getBaseProperty()); assertEquals("derived1 prop val", derived1.getDerived1Property()); } // There seems to be some problems if type is also visible... public void testIssue831() throws Exception { final String JSON = "{ \"petType\": \"dog\",\n" +"\"pet\": { \"name\": \"Pluto\" }\n}"; House831 result = MAPPER.readValue(JSON, House831.class); assertNotNull(result); assertNotNull(result.pet); assertSame(Dog.class, result.pet.getClass()); assertEquals("dog", result.petType); } // For [Issue#96]: should allow use of default impl, if property missing /* 18-Jan-2013, tatu: Unfortunately this collides with [Issue#118], and I don't * know what

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) .readValue(json); assertEquals(w.typeEnum, w2.typeEnum); assertTrue(String.format("Expected %s = %s; got back %s = %s", w.value.getClass().getSimpleName(), w.value.toString(), w2.value.getClass().getSimpleName(), w2.value.toString()), w.value.equals(w2.value)); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { kind = Std.STD_JAVA_TYPE; } else if (rawType == Currency.class) { kind = Std.STD_CURRENCY; } else if (rawType == Pattern.class) { kind = Std.STD_PATTERN; } else if (rawType == Locale.class) { kind = Std.STD_LOCALE; } else if (rawType == Charset.class) { kind = Std.STD_CHARSET; } else if (rawType == TimeZone.class) { kind = Std.STD_TIME_ZONE; } else if (rawType == InetAddress.class) { kind = Std.STD_INET_ADDRESS; } else if (rawType == InetSocketAddress.class) { kind = Std.STD_INET_SOCKET_ADDRESS; } else { return null; } return new Std(rawType, kind); } /* /********************************************************** /* Deserializer implementations /********************************************************** */ @SuppressWarnings("unchecked") @Override public T deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { // Issue#381 if (jp.getCurrentToken() == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final T value = deserialize(jp, ctxt); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _valueClass.getName() + "' value but there was more than a single value in the array"); } return value; } // 22-Sep-2012, tatu: For 2.1, use this new method, may force coercion: String text = jp.getValueAsString(); if (text != null) { // has String representation if (text.length() == 0 || (text = text.trim()).length() == 0) { // 04-Feb-2013, tatu: Usually should become null; but not always return _deserializeFromEmptyString(); } Exception cause = null; try { T result = _deserialize(text, ctxt

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.util.Iterator; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContainerSerializer; import com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase; @SuppressWarnings("serial") @JacksonStdImpl public class IteratorSerializer extends AsArraySerializerBase<Iterator<?>> { public IteratorSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts) { super(Iterator.class, elemType, staticTyping, vts, null); } public IteratorSerializer(IteratorSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle) { super(src, property, vts, valueSerializer, unwrapSingle); } @Override public boolean isEmpty(SerializerProvider prov, Iterator<?> value) { return (value == null) || !value.hasNext(); } @Override public boolean hasSingleElement(Iterator<?> value) { // no really good way to determine (without consuming iterator), so: return false; } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new IteratorSerializer(this, _property, vts, _elementSerializer, _unwrapSingle); } @Override public IteratorSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new IteratorSerializer(this, property, vts, elementSerializer, unwrapSingle); } @Override public final void serialize(Iterator<?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { if (hasSingleElement(value)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(); serializeContents(value, gen,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> // always suppress nulls suppressNulls = true; // but possibly also 'empty' values: valueToSuppress = BeanPropertyWriter.MARKER_FOR_EMPTY; break; case NON_NULL: suppressNulls = true; // fall through case ALWAYS: // default default: // we may still want to suppress empty collections, as per [JACKSON-254]: if (declaredType.isContainerType() && !_config.isEnabled(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS)) { valueToSuppress = BeanPropertyWriter.MARKER_FOR_EMPTY; } break; } BeanPropertyWriter bpw = new BeanPropertyWriter(propDef, am, _beanDesc.getClassAnnotations(), declaredType, ser, typeSer, serializationType, suppressNulls, valueToSuppress); // How about custom null serializer? Object serDef = _annotationIntrospector.findNullSerializer(am); if (serDef != null) { bpw.assignNullSerializer(prov.serializerInstance(am, serDef)); } // And then, handling of unwrapping NameTransformer unwrapper = _annotationIntrospector.findUnwrappingNameTransformer(am); if (unwrapper != null) { bpw = bpw.unwrappingWriter(unwrapper); } return bpw; } /* /********************************************************** /* Helper methods; annotation access /********************************************************** */ /** * Method that will try to determine statically defined type of property * being serialized, based on annotations (for overrides), and alternatively * declared type (if static typing for serialization is enabled). * If neither can be used (no annotations, dynamic typing), returns null. */ protected JavaType findSerializationType(Annotated a, boolean useStaticTyping, JavaType declaredType) { // [JACKSON-120]: Check to see if serialization type is fixed Class<?> serClass = _annotationIntrospector.findSerializationType(a); if (serClass != null) { // Must be a super type to be usable Class<?> rawDeclared = declaredType.getRawClass(); if (serClass.isAssignableFrom(rawDeclared)) { declaredType = declaredType.widenBy(serClass); } else { /* 1

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>s, * let's cache instances by default. */ @Override public boolean isCachable() { return true; } @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken curr = p.getCurrentToken(); // Usually should just get string value: if (curr == JsonToken.VALUE_STRING || curr == JsonToken.FIELD_NAME) { String name = p.getText(); Object result = _enumLookup.find(name); if (result == null) { return _deserializeAltString(p, ctxt, name); } return result; } // But let's consider int acceptable as well (if within ordinal range) if (curr == JsonToken.VALUE_NUMBER_INT) { // ... unless told not to do that. :-) (as per [JACKSON-412]) _checkFailOnNumber(ctxt); int index = p.getIntValue(); if (index >= 0 && index <= _enumsByIndex.length) { return _enumsByIndex[index]; } if (!ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdNumberException(Integer.valueOf(index), _enumClass(), "index value outside legal index range [0.."+(_enumsByIndex.length-1)+"]"); } return null; } return _deserializeOther(p, ctxt); } private final Object _deserializeAltString(JsonParser p, DeserializationContext ctxt, String name) throws IOException { name = name.trim(); if (name.length() == 0) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { return null; } } else { // [#149]: Allow use of 'String' indexes as well char c = name.charAt(0); if (c >= '0' && c <= '9') { try { int ix = Integer.parseInt(name); _checkFailOnNumber(ctxt); if (ix >= 0 && ix <= _enumsByIndex.length) { return _enumsByIndex[ix]; } } catch (NumberFormatException e) { // fine,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> ignore, was not an integer } } } if (!ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdStringException(name, _enumClass(), "value not one of declared Enum instance names: "+_enumLookup.keys()); } return null; } protected Object _deserializeOther(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken curr = p.getCurrentToken(); // [databind#381] if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS) && p.isExpectedStartArrayToken()) { p.nextToken(); final Object parsed = deserialize(p, ctxt); curr = p.nextToken(); if (curr != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _enumClass().getName() + "' value but there was more than a single value in the array"); } return parsed; } throw ctxt.mappingException(_enumClass()); } protected void _checkFailOnNumber(DeserializationContext ctxt) throws IOException { if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS)) { throw ctxt.mappingException("Not allowed to deserialize Enum value out of JSON number (disable DeserializationConfig.DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS to allow)"); } } protected Class<?> _enumClass() { return handledType(); } /* /********************************************************** /* Additional helper classes /********************************************************** */ /** * Deserializer that uses a single-String static factory method * for locating Enum values by String id. */ protected static class FactoryBasedDeserializer extends StdDeserializer<Object> implements ContextualDeserializer { private static final long serialVersionUID = 1; // Marker type; null if String expected; otherwise numeric wrapper protected final Class<?> _inputType; protected final Method _factory; protected final JsonDeserializer<?> _deser; public FactoryBasedDeserializer(Class<?> cls, AnnotatedMethod f, Class<?> inputType) { super(cls); _factory = f.getAnnotated(); _inputType

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> // [databind#749]: or via toString()? if (serializers.isEnabled(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)) { gen.writeString(en.toString()); return; } gen.writeString(_values.serializedValueFor(en)); } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { // [JACKSON-684]: serialize as index? if (_serializeAsIndex(provider)) { return createSchemaNode("integer", true); } ObjectNode objectNode = createSchemaNode("string", true); if (typeHint != null) { JavaType type = provider.constructType(typeHint); if (type.isEnumType()) { ArrayNode enumNode = objectNode.putArray("enum"); for (SerializableString value : _values.values()) { enumNode.add(value.getValue()); } } } return objectNode; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { SerializerProvider serializers = visitor.getProvider(); if (_serializeAsIndex(serializers)) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { // typically serialized as a small number (byte or int) v2.numberType(JsonParser.NumberType.INT); } return; } JsonStringFormatVisitor stringVisitor = visitor.expectStringFormat(typeHint); if (stringVisitor != null) { Set<String> enums = new LinkedHashSet<String>(); // Use toString()? if ((serializers != null) && serializers.isEnabled(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)) { for (Enum<?> e : _values.enums()) { enums.add(e.toString()); } } else { // No, serialize using name() or explicit overrides for (SerializableString value : _values.values()) { enums.add(value.getValue()); } } stringVisitor.enumTypes(enums); } } /* /********************************************************** /* Helper methods /********************************************************** */ protected final boolean _serializeAsIndex(SerializerProvider serializers) { if (_serialize

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>AsIndex != null) { return _serializeAsIndex.booleanValue(); } return serializers.isEnabled(SerializationFeature.WRITE_ENUMS_USING_INDEX); } /** * Helper method called to check whether */ protected static Boolean _isShapeWrittenUsingIndex(Class<?> enumClass, JsonFormat.Value format, boolean fromClass) { JsonFormat.Shape shape = (format == null) ? null : format.getShape(); if (shape == null) { return null; } if (shape == Shape.ANY || shape == Shape.SCALAR) { // i.e. "default", check dynamically return null; } if (shape == Shape.STRING) { return Boolean.FALSE; } // 01-Oct-2014, tatu: For convenience, consider "as-array" to also mean 'yes, use index') if (shape.isNumeric() || (shape == Shape.ARRAY)) { return Boolean.TRUE; } throw new IllegalArgumentException("Unsupported serialization shape ("+shape+") for Enum "+enumClass.getName() +", not supported as " + (fromClass? "class" : "property") +" annotation"); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>014, tatu: As per [databind#299], may also just let unresolved refs be... if (!isEnabled(DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS)) { return; } UnresolvedForwardReference exception = null; for (Entry<IdKey,ReadableObjectId> entry : _objectIds.entrySet()) { ReadableObjectId roid = entry.getValue(); if (!roid.hasReferringProperties()) { continue; } // as per [databind#675], allow resolution at this point if (tryToResolveUnresolvedObjectId(roid)) { continue; } if (exception == null) { exception = new UnresolvedForwardReference("Unresolved forward references for: "); } Object key = roid.getKey().key; for (Iterator<Referring> iterator = roid.referringProperties(); iterator.hasNext(); ) { Referring referring = iterator.next(); exception.addUnresolvedId(key, referring.getBeanType(), referring.getLocation()); } } if (exception != null) { throw exception; } } /** * Overridable helper method called to try to resolve otherwise unresolvable {@link ReadableObjectId}; * and if this succeeds, return <code>true</code> to indicate problem has been resolved in * some way, so that caller can avoid reporting it as an error. *<p> * Default implementation simply calls {@link ReadableObjectId#tryToResolveUnresolved} and * returns whatever it returns. * * @since 2.6 */ protected boolean tryToResolveUnresolvedObjectId(ReadableObjectId roid) { return roid.tryToResolveUnresolved(this); } /* /********************************************************** /* Abstract methods impls, other factory methods /********************************************************** */ @SuppressWarnings("unchecked") @Override public JsonDeserializer<Object> deserializerInstance(Annotated ann, Object deserDef) throws JsonMappingException { if (deserDef == null) { return null; } JsonDeserializer<?> deser; if (deserDef instanceof JsonDeserializer) { deser = (JsonDeserializer<?>) deserDef; } else { /* Alas, there's no way to force return type of "either class *

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> but we need to let key deserializer handle it separately, nonetheless Enum<?> key = (Enum<?>) _keyDeserializer.deserializeKey(keyName, ctxt); if (key == null) { if (!ctxt.isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdStringException(keyName, _enumClass, "value not one of declared Enum instance names for " +_mapType.getKeyType()); } /* 24-Mar-2012, tatu: Null won't work as a key anyway, so let's * just skip the entry then. But we must skip the value as well, if so. */ jp.nextToken(); jp.skipChildren(); continue; } // And then the value... JsonToken t = jp.nextToken(); /* note: MUST check for nulls separately: deserializers will * not handle them (and maybe fail or return bogus data) */ Object value; try { if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(ctxt); } else if (typeDeser == null) { value = valueDes.deserialize(jp, ctxt); } else { value = valueDes.deserializeWithType(jp, ctxt, typeDeser); } } catch (Exception e) { wrapAndThrow(e, result, keyName); return null; } result.put(key, value); } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromObject(jp, ctxt); } protected EnumMap<?,?> constructMap() { return new EnumMap(_enumClass); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>+SAMPLE_SPEC_VALUE_TN_ID4+"]\n" +" }" +"}" ; /* /********************************************************** /* Helper classes (beans) /********************************************************** */ /** * Sample class from Jackson tutorial ("JacksonInFiveMinutes") */ protected static class FiveMinuteUser { public enum Gender { MALE, FEMALE }; public static class Name { private String _first, _last; public Name() { } public Name(String f, String l) { _first = f; _last = l; } public String getFirst() { return _first; } public String getLast() { return _last; } public void setFirst(String s) { _first = s; } public void setLast(String s) { _last = s; } @Override public boolean equals(Object o) { if (o == this) return true; if (o == null || o.getClass() != getClass()) return false; Name other = (Name) o; return _first.equals(other._first) && _last.equals(other._last); } } private Gender _gender; private Name _name; private boolean _isVerified; private byte[] _userImage; public FiveMinuteUser() { } public FiveMinuteUser(String first, String last, boolean verified, Gender g, byte[] data) { _name = new Name(first, last); _isVerified = verified; _gender = g; _userImage = data; } public Name getName() { return _name; } public boolean isVerified() { return _isVerified; } public Gender getGender() { return _gender; } public byte[] getUserImage() { return _userImage; } public void setName(Name n) { _name = n; } public void setVerified(boolean b) { _isVerified = b; } public void setGender(Gender g) { _gender = g; } public void setUserImage(byte[] b) { _userImage = b; } @Override public boolean equals(Object o) { if (o == this) return true; if (o == null || o.getClass() != getClass()) return

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> */ public SequenceWriter writeValuesAsArray(OutputStream out) throws IOException { return _newSequenceWriter(true, _generatorFactory.createGenerator(out, JsonEncoding.UTF8), true); } /* /********************************************************** /* Simple accessors /********************************************************** */ public boolean isEnabled(SerializationFeature f) { return _config.isEnabled(f); } public boolean isEnabled(MapperFeature f) { return _config.isEnabled(f); } public boolean isEnabled(JsonParser.Feature f) { return _generatorFactory.isEnabled(f); } /** * @since 2.2 */ public SerializationConfig getConfig() { return _config; } /** * @since 2.2 */ public JsonFactory getFactory() { return _generatorFactory; } public TypeFactory getTypeFactory() { return _config.getTypeFactory(); } /** * Diagnostics method that can be called to check whether this writer * has pre-fetched serializer to use: pre-fetching improves performance * when writer instances are reused as it avoids a per-call serializer * lookup. * * @since 2.2 */ public boolean hasPrefetchedSerializer() { return _prefetch.hasSerializer(); } /** * @since 2.3 */ public ContextAttributes getAttributes() { return _config.getAttributes(); } /* /********************************************************** /* Serialization methods; ones from ObjectCodec first /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, using provided {@link JsonGenerator}. */ public void writeValue(JsonGenerator gen, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSEABLE) && (value instanceof Closeable)) { Closeable toClose = (Closeable) value; try { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } Closeable tmpToClose = toClose; toClose = null; tmpToClose.close(); } finally { if (toClose

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> != null) { try { toClose.close(); } catch (IOException ioe) { } } } } else { _prefetch.serialize(gen, value, _serializerProvider()); if (_config.isEnabled(SerializationFeature.FLUSH_AFTER_WRITE_VALUE)) { gen.flush(); } } } /* /********************************************************** /* Serialization methods, others /********************************************************** */ /** * Method that can be used to serialize any Java value as * JSON output, written to File provided. */ public void writeValue(File resultFile, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(resultFile, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using output stream provided (using encoding * {@link JsonEncoding#UTF8}). *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(OutputStream out, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(out, JsonEncoding.UTF8), value); } /** * Method that can be used to serialize any Java value as * JSON output, using Writer provided. *<p> * Note: method does not close the underlying stream explicitly * here; however, {@link JsonFactory} this mapper uses may choose * to close the stream depending on its settings (by default, * it will try to close it when {@link JsonGenerator} we construct * is closed). */ public void writeValue(Writer w, Object value) throws IOException, JsonGenerationException, JsonMappingException { _configAndWriteValue(_generatorFactory.createGenerator(w), value); } /** * Method that can be used to serialize any Java value as * a String. Functionally equivalent to calling * {@link #writeValue(Writer,Object)} with {@link java.io

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> like * generating <a href="http://json-schema.org/">Json Schema</a> * instance for specified type. * * @param type Type to generate schema for (possibly with generic signature) * * @since 2.2 */ public void acceptJsonFormatVisitor(JavaType type, JsonFormatVisitorWrapper visitor) throws JsonMappingException { if (type == null) { throw new IllegalArgumentException("type must be provided"); } _serializerProvider().acceptJsonFormatVisitor(type, visitor); } /** * Since 2.6 */ public void acceptJsonFormatVisitor(Class<?> rawType, JsonFormatVisitorWrapper visitor) throws JsonMappingException { acceptJsonFormatVisitor(_config.constructType(rawType), visitor); } public boolean canSerialize(Class<?> type) { return _serializerProvider().hasSerializerFor(type, null); } /** * Method for checking whether instances of given type can be serialized, * and optionally why (as per {@link Throwable} returned). * * @since 2.3 */ public boolean canSerialize(Class<?> type, AtomicReference<Throwable> cause) { return _serializerProvider().hasSerializerFor(type, cause); } /* /********************************************************** /* Overridable helper methods /********************************************************** */ /** * Overridable helper method used for constructing * {@link SerializerProvider} to use for serialization. */ protected DefaultSerializerProvider _serializerProvider() { return _serializerProvider.createInstance(_config, _serializerFactory); } /* /********************************************************** /* Internal methods /********************************************************** */ /** * @since 2.2 */ protected void _verifySchemaType(FormatSchema schema) { if (schema != null) { if (!_generatorFactory.canUseSchema(schema)) { throw new IllegalArgumentException("Can not use FormatSchema of type "+schema.getClass().getName() +" for format "+_generatorFactory.getFormatName()); } } } /** * Method called to configure the generator as necessary and then * call write functionality */ protected final void _configAndWriteValue(JsonGenerator gen, Object value) throws IOException { _configureGenerator(gen); if (_config.isEnabled(SerializationFeature.CLOSE_CLOSE

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, but usually one of its super types * (parent class or interface it implements). */ private final JavaType rootType; /** * We may pre-fetch serializer if {@link #rootType} * is known, and if so, reuse it afterwards. * This allows avoiding further serializer lookups and increases * performance a bit on cases where readers are reused. */ private final JsonSerializer<Object> valueSerializer; /** * When dealing with polymorphic types, we can not pre-fetch * serializer, but can pre-fetch {@link TypeSerializer}. */ private final TypeSerializer typeSerializer; private Prefetch(JavaType rootT, JsonSerializer<Object> ser, TypeSerializer typeSer) { rootType = rootT; valueSerializer = ser; typeSerializer = typeSer; } public Prefetch forRootType(ObjectWriter parent, JavaType newType) { // First: if nominal type not defined, or trivial (java.lang.Object), // not thing much to do boolean noType = (newType == null) || newType.isJavaLangObject(); if (noType) { if ((rootType == null) || (valueSerializer == null)) { return this; } return new Prefetch(null, null, typeSerializer); } if (newType.equals(rootType)) { return this; } if (parent.isEnabled(SerializationFeature.EAGER_SERIALIZER_FETCH)) { DefaultSerializerProvider prov = parent._serializerProvider(); // 17-Dec-2014, tatu: Need to be bit careful here; TypeSerializers are NOT cached, // so although it'd seem like a good idea to look for those first, and avoid // serializer for polymorphic types, it is actually more efficient to do the // reverse here. try { JsonSerializer<Object> ser = prov.findTypedValueSerializer(newType, true, null); // Important: for polymorphic types, "unwrap"... if (ser instanceof TypeWrappedSerializer) { return new Prefetch(newType, null, ((TypeWrappedSerializer) ser).typeSerializer()); } return new Prefetch(newType, ser, null); } catch (JsonProcessingException e) { // need to

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>deserialize(p, ctxt)); if (_injectables != null) { injectValues(ctxt, bean); } return bean; } catch (Exception e) { wrapInstantiationProblem(e, ctxt); } } if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)) { return null; } final Object value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _valueClass.getName() + "' value but there was more than a single value in the array"); } return value; } if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)) { JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } throw ctxt.mappingException(handledType(), JsonToken.START_ARRAY); } throw ctxt.mappingException(handledType()); } public Object deserializeFromEmbedded(JsonParser jp, DeserializationContext ctxt) throws IOException { // First things first: id Object Id is used, most likely that's it; specifically, // true for UUIDs when written as binary (with Smile, other binary formats) if (_objectIdReader != null) { return deserializeFromObjectId(jp, ctxt); } // TODO: maybe add support for ValueInstantiator, embedded? return jp.getEmbeddedObject(); } /* /********************************************************** /* Overridable helper methods /********************************************************** */ protected void injectValues(DeserializationContext ctxt, Object bean) throws IOException, JsonProcessingException { for (ValueInjector injector : _injectables) { injector.inject(ctxt, bean); } } /** * Method called to handle set of one or more unknown properties, * stored in their entirety in given {@link TokenBuffer} * (as field entries, name and value). */ @SuppressWarnings("resource") protected Object handle

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> ignored property (one specified with a * name to match, either by property annotation or class annotation) is encountered. * * @since 2.3 */ protected void handleIgnoredProperty(JsonParser jp, DeserializationContext ctxt, Object beanOrClass, String propName) throws IOException, JsonProcessingException { if (ctxt.isEnabled(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES)) { throw IgnoredPropertyException.from(jp, beanOrClass, propName, getKnownPropertyNames()); } jp.skipChildren(); } /** * Method called in cases where we may have polymorphic deserialization * case: that is, type of Creator-constructed bean is not the type * of deserializer itself. It should be a sub-class or implementation * class; either way, we may have more specific deserializer to use * for handling it. * * @param jp (optional) If not null, parser that has more properties to handle * (in addition to buffered properties); if null, all properties are passed * in buffer */ @SuppressWarnings("resource") protected Object handlePolymorphic(JsonParser jp, DeserializationContext ctxt, Object bean, TokenBuffer unknownTokens) throws IOException, JsonProcessingException { // First things first: maybe there is a more specific deserializer available? JsonDeserializer<Object> subDeser = _findSubclassDeserializer(ctxt, bean, unknownTokens); if (subDeser != null) { if (unknownTokens != null) { // need to add END_OBJECT marker first unknownTokens.writeEndObject(); JsonParser p2 = unknownTokens.asParser(); p2.nextToken(); // to get to first data field bean = subDeser.deserialize(p2, ctxt, bean); } // Original parser may also have some leftovers if (jp != null) { bean = subDeser.deserialize(jp, ctxt, bean); } return bean; } // nope; need to use this deserializer. Unknowns we've seen so far? if (unknownTokens != null) { bean = handleUnknownProperties(ctxt, bean, unknownTokens); } // and/or things left to process via main parser? if (jp != null) {

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>} are to be passed as is *</ul> */ public void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(throwOrReturnThrowable(t, ctxt), bean, fieldName); } @Deprecated // since 2.4, not used by core Jackson; only relevant for arrays/Collections public void wrapAndThrow(Throwable t, Object bean, int index, DeserializationContext ctxt) throws IOException { // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(throwOrReturnThrowable(t, ctxt), bean, index); } private Throwable throwOrReturnThrowable(Throwable t, DeserializationContext ctxt) throws IOException { /* 05-Mar-2009, tatu: But one nasty edge is when we get * StackOverflow: usually due to infinite loop. But that * often gets hidden within an InvocationTargetException... */ while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors to be passed as is if (t instanceof Error) { throw (Error) t; } boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); // Ditto for IOExceptions; except we may want to wrap JSON exceptions if (t instanceof IOException) { if (!wrap || !(t instanceof JsonProcessingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } return t; } protected void wrapInstantiationProblem(Throwable t, DeserializationContext ctxt) throws IOException { while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" IOExceptions to be passed as is if (t instanceof Error) { throw (Error) t; } boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { return _config.getLocale(); } /** * Method for accessing default TimeZone to use: convenience method for *<pre> * getConfig().getTimeZone(); *</pre> */ @Override public TimeZone getTimeZone() { return _config.getTimeZone(); } /* /********************************************************** /* Generic attributes (2.3+) /********************************************************** */ @Override public Object getAttribute(Object key) { return _attributes.getAttribute(key); } @Override public SerializerProvider setAttribute(Object key, Object value) { _attributes = _attributes.withPerCallAttribute(key, value); return this; } /* /********************************************************** /* Access to general configuration /********************************************************** */ /** * Convenience method for checking whether specified serialization * feature is enabled or not. * Shortcut for: *<pre> * getConfig().isEnabled(feature); *</pre> */ public final boolean isEnabled(SerializationFeature feature) { return _config.isEnabled(feature); } /** * "Bulk" access method for checking that all features specified by * mask are enabled. * * @since 2.3 */ public final boolean hasSerializationFeatures(int featureMask) { return _config.hasSerializationFeatures(featureMask); } /** * Convenience method for accessing provider to find serialization filters used, * equivalent to calling: *<pre> * getConfig().getFilterProvider(); *</pre> */ public final FilterProvider getFilterProvider() { return _config.getFilterProvider(); } /* /********************************************************** /* Access to Object Id aspects /********************************************************** */ /** * Method called to find the Object Id for given POJO, if one * has been generated. Will always return a non-null Object; * contents vary depending on whether an Object Id already * exists or not. */ public abstract WritableObjectId findObjectId(Object forPojo, ObjectIdGenerator<?> generatorType); /* /********************************************************** /* General serializer locating functionality /********************************************************** */ /** * Method called to get hold of a serializer for a value of given type; * or if no such serializer can be found, a default handler (which * may

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>-Apr-2015, tatu: "empty" serializer is trickier; needs to consider // error handling if (isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { if (ser.getClass() == UnknownSerializer.class) { return true; } } return false; } /* /********************************************************** /* Methods for creating instances based on annotations /********************************************************** */ /** * Method that can be called to construct and configure serializer instance, * either given a {@link Class} to instantiate (with default constructor), * or an uninitialized serializer instance. * Either way, serialize will be properly resolved * (via {@link com.fasterxml.jackson.databind.ser.ResolvableSerializer}) and/or contextualized * (via {@link com.fasterxml.jackson.databind.ser.ContextualSerializer}) as necessary. * * @param annotated Annotated entity that contained definition * @param serDef Serializer definition: either an instance or class */ public abstract JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException; /* /********************************************************** /* Support for contextualization /********************************************************** */ /** * Method called for primary property serializers (ones * directly created to serialize values of a POJO property), * to handle details of resolving * {@link ContextualSerializer} with given property context. * * @param property Property for which the given primary serializer is used; never null. * * @since 2.3 */ public JsonSerializer<?> handlePrimaryContextualization(JsonSerializer<?> ser, BeanProperty property) throws JsonMappingException { if (ser != null) { if (ser instanceof ContextualSerializer) { ser = ((ContextualSerializer) ser).createContextual(this, property); } } return ser; } /** * Method called for secondary property serializers (ones * NOT directly created to serialize values of a POJO property * but instead created as a dependant serializer -- such as value serializers * for structured types, or serializers for root values) * to handle details of resolving * {@link ContextualDeserializer} with given property context. * Given that these serializers are not directly related to given property * (or, in case of

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> that will handle serialization of Date(-like) values, using * {@link SerializationConfig} settings to determine expected serialization * behavior. * Note: date here means "full" date, that is, date AND time, as per * Java convention (and not date-only values like in SQL) */ public final void defaultSerializeDateValue(long timestamp, JsonGenerator gen) throws IOException { if (isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) { gen.writeNumber(timestamp); } else { gen.writeString(_dateFormat().format(new Date(timestamp))); } } /** * Method that will handle serialization of Date(-like) values, using * {@link SerializationConfig} settings to determine expected serialization * behavior. * Note: date here means "full" date, that is, date AND time, as per * Java convention (and not date-only values like in SQL) */ public final void defaultSerializeDateValue(Date date, JsonGenerator gen) throws IOException { if (isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)) { gen.writeNumber(date.getTime()); } else { gen.writeString(_dateFormat().format(date)); } } /** * Method that will handle serialization of Dates used as {@link java.util.Map} keys, * based on {@link SerializationFeature#WRITE_DATE_KEYS_AS_TIMESTAMPS} * value (and if using textual representation, configured date format) */ public void defaultSerializeDateKey(long timestamp, JsonGenerator gen) throws IOException { if (isEnabled(SerializationFeature.WRITE_DATE_KEYS_AS_TIMESTAMPS)) { gen.writeFieldName(String.valueOf(timestamp)); } else { gen.writeFieldName(_dateFormat().format(new Date(timestamp))); } } /** * Method that will handle serialization of Dates used as {@link java.util.Map} keys, * based on {@link SerializationFeature#WRITE_DATE_KEYS_AS_TIMESTAMPS} * value (and if using textual representation, configured date format) */ public void defaultSerializeDateKey(Date date, JsonGenerator gen) throws IOException { if (isEnabled(SerializationFeature.WRITE_DATE_KEYS_AS_

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind; import com.fasterxml.jackson.databind.cfg.ConfigFeature; /** * Enumeration that defines simple on/off features that affect * the way Java objects are deserialized from JSON *<p> * Note that features can be set both through * {@link ObjectMapper} (as sort of defaults) and through * {@link ObjectReader}. * In first case these defaults must follow "config-then-use" patterns * (i.e. defined once, not changed afterwards); all per-call * changes must be done using {@link ObjectReader}. *<p> * Note that features that do not indicate version of inclusion * were available in Jackson 2.0 (or earlier); only later additions * indicate version of inclusion. */ public enum DeserializationFeature implements ConfigFeature { /* /****************************************************** /* Type conversion features /****************************************************** */ /** * Feature that determines whether JSON floating point numbers * are to be deserialized into {@link java.math.BigDecimal}s * if only generic type description (either {@link Object} or * {@link Number}, or within untyped {@link java.util.Map} * or {@link java.util.Collection} context) is available. * If enabled such values will be deserialized as {@link java.math.BigDecimal}s; * if disabled, will be deserialized as {@link Double}s. * <p> * Feature is disabled by default, meaning that "untyped" floating * point numbers will by default be deserialized as {@link Double}s * (choice is for performance reason -- BigDecimals are slower than * Doubles). */ USE_BIG_DECIMAL_FOR_FLOATS(false), /** * Feature that determines whether JSON integral (non-floating-point) * numbers are to be deserialized into {@link java.math.BigInteger}s * if only generic type description (either {@link Object} or * {@link Number}, or within untyped {@link java.util.Map} * or {@link java.util.Collection} context) is available. * If enabled such values will be deserialized as * {@link java.math.BigInteger}s; * if disabled, will be deserialized as "smallest" available type, * which is either

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>>if and only if</b> datatype supports such resolution. * Only newer datatypes (such as Java8 Date/Time) support such resolution -- * older types (pre-Java8 <b>java.util.Date</b> etc) and Joda do not -- * and this setting <b>has no effect</b> on such types. *<p> * If disabled, standard millisecond timestamps are assumed. * This is the counterpart to {@link SerializationFeature#WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS}. *<p> * Feature is enabled by default, to support most accurate time values possible. * * @since 2.2 */ READ_DATE_TIMESTAMPS_AS_NANOSECONDS(true), /** * Feature that specifies whether context provided {@link java.util.TimeZone} * ({@link DeserializationContext#getTimeZone()} should be used to adjust Date/Time * values on deserialization, even if value itself contains timezone information. * If enabled, contextual <code>TimeZone</code> will essentially override any other * TimeZone information; if disabled, it will only be used if value itself does not * contain any TimeZone information. * * @since 2.2 */ ADJUST_DATES_TO_CONTEXT_TIME_ZONE(true), /* /****************************************************** /* Other /****************************************************** */ /** * Feature that determines whether {@link ObjectReader} should * try to eagerly fetch necessary {@link JsonDeserializer} when * possible. This improves performance in cases where similarly * configured {@link ObjectReader} instance is used multiple * times; and should not significantly affect single-use cases. *<p> * Note that there should not be any need to normally disable this * feature: only consider that if there are actual perceived problems. *<p> * Feature is enabled by default. * * @since 2.1 */ EAGER_DESERIALIZER_FETCH(true) ; private final boolean _defaultState; private final int _mask; private DeserializationFeature(boolean defaultState) { _defaultState = defaultState; _mask = (1 << ordinal()); } @Override public boolean enabledByDefault() { return

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.node; import java.io.IOException; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.SerializerProvider; /** * This concrete value class is used to contain boolean (true / false) * values. Only two instances are ever created, to minimize memory * usage. */ public class BooleanNode extends ValueNode { // // Just need two instances... public final static BooleanNode TRUE = new BooleanNode(true); public final static BooleanNode FALSE = new BooleanNode(false); private final boolean _value; private BooleanNode(boolean v) { _value = v; } public static BooleanNode getTrue() { return TRUE; } public static BooleanNode getFalse() { return FALSE; } public static BooleanNode valueOf(boolean b) { return b ? TRUE : FALSE; } @Override public JsonNodeType getNodeType() { return JsonNodeType.BOOLEAN; } @Override public JsonToken asToken() { return _value ? JsonToken.VALUE_TRUE : JsonToken.VALUE_FALSE; } @Override public boolean booleanValue() { return _value; } @Override public String asText() { return _value ? "true" : "false"; } @Override public boolean asBoolean() { return _value; } @Override public boolean asBoolean(boolean defaultValue) { return _value; } @Override public int asInt(int defaultValue) { return _value ? 1 : 0; } @Override public long asLong(long defaultValue) { return _value ? 1L : 0L; } @Override public double asDouble(double defaultValue) { return _value ? 1.0 : 0.0; } @Override public final void serialize(JsonGenerator g, SerializerProvider provider) throws IOException { g.writeBoolean(_value); } @Override public int hashCode() { return _value ? 3 : 1; } @Override public boolean equals(Object o) { /* 11-Mar-2013, tatu: Apparently ClassLoaders can manage to load * different instances, rendering identity comparisons broken

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>put(typeId, deser); } return deser; } protected final JsonDeserializer<Object> _findDefaultImplDeserializer(DeserializationContext ctxt) throws IOException { /* 06-Feb-2013, tatu: As per [Issue#148], consider default implementation value of * {@link java.lang.Void} to mean "serialize as null"; as well as DeserializationFeature * to do swift mapping to null */ if (_defaultImpl == null) { if (!ctxt.isEnabled(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE)) { return NullifyingDeserializer.instance; } return null; } Class<?> raw = _defaultImpl.getRawClass(); if (ClassUtil.isBogusClass(raw)) { return NullifyingDeserializer.instance; } synchronized (_defaultImpl) { if (_defaultImplDeserializer == null) { _defaultImplDeserializer = ctxt.findContextualValueDeserializer( _defaultImpl, _property); } return _defaultImplDeserializer; } } /** * Helper method called when {@link JsonParser} indicates that it can use * so-called native type ids. Assumption from there is that only native * type ids are to be used. * * @since 2.3 */ @Deprecated protected Object _deserializeWithNativeTypeId(JsonParser jp, DeserializationContext ctxt) throws IOException { return _deserializeWithNativeTypeId(jp, ctxt, jp.getTypeId()); } /** * Helper method called when {@link JsonParser} indicates that it can use * so-called native type ids, and such type id has been found. * * @since 2.4 */ protected Object _deserializeWithNativeTypeId(JsonParser jp, DeserializationContext ctxt, Object typeId) throws IOException { JsonDeserializer<Object> deser; if (typeId == null) { /* 04-May-2014, tatu: Should error be obligatory, or should there be another method * for "try to deserialize with native tpye id"? */ deser = _findDefaultImplDeserializer(ctxt); if (deser == null) { throw ctxt.mappingException("No (native) type id found when one was expected

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Single == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { _serializeUnwrapped(value, gen, provider); return; } } gen.writeStartArray(len); if (_serializer == null) { serializeContents(value, gen, provider, len); } else { serializeUsingCustom(value, gen, provider, len); } gen.writeEndArray(); } private final void _serializeUnwrapped(List<String> value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (_serializer == null) { serializeContents(value, gen, provider, 1); } else { serializeUsingCustom(value, gen, provider, 1); } } @Override public void serializeWithType(List<String> value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { final int len = value.size(); typeSer.writeTypePrefixForArray(value, gen); if (_serializer == null) { serializeContents(value, gen, provider, len); } else { serializeUsingCustom(value, gen, provider, len); } typeSer.writeTypeSuffixForArray(value, gen); } private final void serializeContents(List<String> value, JsonGenerator gen, SerializerProvider provider, int len) throws IOException { int i = 0; try { for (; i < len; ++i) { String str = value.get(i); if (str == null) { provider.defaultSerializeNull(gen); } else { gen.writeString(str); } } } catch (Exception e) { wrapAndThrow(provider, e, value, i); } } private final void serializeUsingCustom(List<String> value, JsonGenerator gen, SerializerProvider provider, int len) throws IOException { int i = 0; try { final JsonSerializer<String> ser = _serializer; for (i = 0; i < len; ++i) { String str = value.get(i); if (str == null) { provider.defaultSerializeNull(gen); }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.*; import java.nio.ByteBuffer; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.util.ByteBufferBackedOutputStream; public class ByteBufferDeserializer extends StdScalarDeserializer<ByteBuffer> { private static final long serialVersionUID = 1L; protected ByteBufferDeserializer() { super(ByteBuffer.class); } @Override public ByteBuffer deserialize(JsonParser parser, DeserializationContext cx) throws IOException { byte[] b = parser.getBinaryValue(); return ByteBuffer.wrap(b); } @Override public ByteBuffer deserialize(JsonParser jp, DeserializationContext ctxt, ByteBuffer intoValue) throws IOException { // Let's actually read in streaming manner... OutputStream out = new ByteBufferBackedOutputStream(intoValue); jp.readBinaryValue(ctxt.getBase64Variant(), out); out.close(); return intoValue; } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatTypes; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.std.StaticListSerializerBase; /** * Efficient implement for serializing {@link Collection}s that contain Strings. * The only complexity is due to possibility that serializer for {@link String} * may be overridde; because of this, logic is needed to ensure that the default * serializer is in use to use fastest mode, or if not, to defer to custom * String serializer. */ @JacksonStdImpl @SuppressWarnings("serial") public class StringCollectionSerializer extends StaticListSerializerBase<Collection<String>> { public final static StringCollectionSerializer instance = new StringCollectionSerializer(); /* /********************************************************** /* Life-cycle /********************************************************** */ protected StringCollectionSerializer() { super(Collection.class); } protected StringCollectionSerializer(StringCollectionSerializer src, JsonSerializer<?> ser, Boolean unwrapSingle) { super(src, ser, unwrapSingle); } @Override public JsonSerializer<?> _withResolved(BeanProperty prop, JsonSerializer<?> ser, Boolean unwrapSingle) { return new StringCollectionSerializer(this, ser, unwrapSingle); } @Override protected JsonNode contentSchema() { return createSchemaNode("string", true); } @Override protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonMappingException { visitor.itemsFormat(JsonFormatTypes.STRING); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public void serialize(Collection<String> value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.ser.impl; import java.io.IOException; import java.lang.reflect.Type; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.std.StdSerializer; @SuppressWarnings("serial") public class UnknownSerializer extends StdSerializer<Object> { public UnknownSerializer() { super(Object.class); } /** * @since 2.6 */ public UnknownSerializer(Class<?> cls) { super(cls, false); } @Override public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { // 27-Nov-2009, tatu: As per [JACKSON-201] may or may not fail... if (provider.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { failForEmpty(value); } // But if it's fine, we'll just output empty JSON Object: gen.writeStartObject(); gen.writeEndObject(); } @Override public final void serializeWithType(Object value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { if (provider.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { failForEmpty(value); } typeSer.writeTypePrefixForObject(value, gen); typeSer.writeTypeSuffixForObject(value, gen); } @Override public boolean isEmpty(SerializerProvider provider, Object value) { return true; } @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) throws JsonMappingException { return null; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { visitor.expectAnyFormat(typeHint); } protected void failForEmpty(Object value) throws JsonMappingException { throw new JsonMappingException("No serializer found for class "+value.getClass().getName()+" and no properties discovered to

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>.findPropertiesToIgnore(ac, forSerialization); } return result; } @Override public Boolean findIgnoreUnknownProperties(AnnotatedClass ac) { Boolean result = _primary.findIgnoreUnknownProperties(ac); if (result == null) { result = _secondary.findIgnoreUnknownProperties(ac); } return result; } @Override public Boolean isIgnorableType(AnnotatedClass ac) { Boolean result = _primary.isIgnorableType(ac); if (result == null) { result = _secondary.isIgnorableType(ac); } return result; } @Deprecated @Override public Object findFilterId(AnnotatedClass ac) { Object id = _primary.findFilterId(ac); if (id == null) { id = _secondary.findFilterId(ac); } return id; } @Override public Object findFilterId(Annotated ann) { Object id = _primary.findFilterId(ann); if (id == null) { id = _secondary.findFilterId(ann); } return id; } @Override public Object findNamingStrategy(AnnotatedClass ac) { Object str = _primary.findNamingStrategy(ac); if (str == null) { str = _secondary.findNamingStrategy(ac); } return str; } /* /****************************************************** /* Property auto-detection /****************************************************** */ @Override public VisibilityChecker<?> findAutoDetectVisibility(AnnotatedClass ac, VisibilityChecker<?> checker) { /* Note: to have proper priorities, we must actually call delegatees * in reverse order: */ checker = _secondary.findAutoDetectVisibility(ac, checker); return _primary.findAutoDetectVisibility(ac, checker); } /* /****************************************************** /* Type handling /****************************************************** */ @Override public TypeResolverBuilder<?> findTypeResolver(MapperConfig<?> config, AnnotatedClass ac, JavaType baseType) { TypeResolverBuilder<?> b = _primary.findTypeResolver(config, ac, baseType); if (b == null) { b = _secondary.findTypeResolver(config, ac, baseType); } return b

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>; } @Override public TypeResolverBuilder<?> findPropertyTypeResolver(MapperConfig<?> config, AnnotatedMember am, JavaType baseType) { TypeResolverBuilder<?> b = _primary.findPropertyTypeResolver(config, am, baseType); if (b == null) { b = _secondary.findPropertyTypeResolver(config, am, baseType); } return b; } @Override public TypeResolverBuilder<?> findPropertyContentTypeResolver(MapperConfig<?> config, AnnotatedMember am, JavaType baseType) { TypeResolverBuilder<?> b = _primary.findPropertyContentTypeResolver(config, am, baseType); if (b == null) { b = _secondary.findPropertyContentTypeResolver(config, am, baseType); } return b; } @Override public List<NamedType> findSubtypes(Annotated a) { List<NamedType> types1 = _primary.findSubtypes(a); List<NamedType> types2 = _secondary.findSubtypes(a); if (types1 == null || types1.isEmpty()) return types2; if (types2 == null || types2.isEmpty()) return types1; ArrayList<NamedType> result = new ArrayList<NamedType>(types1.size() + types2.size()); result.addAll(types1); result.addAll(types2); return result; } @Override public String findTypeName(AnnotatedClass ac) { String name = _primary.findTypeName(ac); if (name == null || name.length() == 0) { name = _secondary.findTypeName(ac); } return name; } // // // General member (field, method/constructor) annotations @Override public ReferenceProperty findReferenceType(AnnotatedMember member) { ReferenceProperty r = _primary.findReferenceType(member); return (r == null) ? _secondary.findReferenceType(member) : r; } @Override public NameTransformer findUnwrappingNameTransformer(AnnotatedMember member) { NameTransformer r = _primary.findUnwrappingNameTransformer(member); return (r == null) ? _secondary.findUnwrappingNameTransformer(member) : r; } @Override public Object findInjectableValueId

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> Class<?>[] result = _primary.findViews(a); if (result == null) { result = _secondary.findViews(a); } return result; } @Override public Boolean isTypeId(AnnotatedMember member) { Boolean b = _primary.isTypeId(member); return (b == null) ? _secondary.isTypeId(member) : b; } @Override public ObjectIdInfo findObjectIdInfo(Annotated ann) { ObjectIdInfo r = _primary.findObjectIdInfo(ann); return (r == null) ? _secondary.findObjectIdInfo(ann) : r; } @Override public ObjectIdInfo findObjectReferenceInfo(Annotated ann, ObjectIdInfo objectIdInfo) { // to give precedence for primary, must start with secondary: objectIdInfo = _secondary.findObjectReferenceInfo(ann, objectIdInfo); objectIdInfo = _primary.findObjectReferenceInfo(ann, objectIdInfo); return objectIdInfo; } @Override public JsonFormat.Value findFormat(Annotated ann) { JsonFormat.Value r = _primary.findFormat(ann); return (r == null) ? _secondary.findFormat(ann) : r; } @Override public PropertyName findWrapperName(Annotated ann) { PropertyName name = _primary.findWrapperName(ann); if (name == null) { name = _secondary.findWrapperName(ann); } else if (name == PropertyName.USE_DEFAULT) { // does the other introspector have a better idea? PropertyName name2 = _secondary.findWrapperName(ann); if (name2 != null) { name = name2; } } return name; } @Override public String findPropertyDefaultValue(Annotated ann) { String str = _primary.findPropertyDefaultValue(ann); return (str == null || str.isEmpty()) ? _secondary.findPropertyDefaultValue(ann) : str; } @Override public String findPropertyDescription(Annotated ann) { String r = _primary.findPropertyDescription(ann); return (r == null) ? _secondary.findPropertyDescription(ann) : r; } @Override public Integer findPropertyIndex(Annotated ann) { Integer r = _

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> /** * Method(s) marked with 'JsonValue' annotation */ protected LinkedList<AnnotatedMethod> _jsonValueGetters; /** * Lazily collected list of properties that can be implicitly * ignored during serialization; only updated when collecting * information for deserialization purposes */ protected HashSet<String> _ignoredPropertyNames; /** * Lazily collected list of members that were annotated to * indicate that they represent mutators for deserializer * value injection. */ protected LinkedHashMap<Object, AnnotatedMember> _injectables; /* /********************************************************** /* Life-cycle /********************************************************** */ protected POJOPropertiesCollector(MapperConfig<?> config, boolean forSerialization, JavaType type, AnnotatedClass classDef, String mutatorPrefix) { _config = config; _stdBeanNaming = config.isEnabled(MapperFeature.USE_STD_BEAN_NAMING); _forSerialization = forSerialization; _type = type; _classDef = classDef; _mutatorPrefix = (mutatorPrefix == null) ? "set" : mutatorPrefix; _annotationIntrospector = config.isAnnotationProcessingEnabled() ? _config.getAnnotationIntrospector() : null; if (_annotationIntrospector == null) { _visibilityChecker = _config.getDefaultVisibilityChecker(); } else { _visibilityChecker = _annotationIntrospector.findAutoDetectVisibility(classDef, _config.getDefaultVisibilityChecker()); } } /* /********************************************************** /* Public API /********************************************************** */ public MapperConfig<?> getConfig() { return _config; } public JavaType getType() { return _type; } public AnnotatedClass getClassDef() { return _classDef; } public AnnotationIntrospector getAnnotationIntrospector() { return _annotationIntrospector; } public List<BeanPropertyDefinition> getProperties() { // make sure we return a copy, so caller can remove entries if need be: Map<String, POJOPropertyBuilder> props = getPropertyMap(); return new ArrayList<BeanPropertyDefinition>(props.values()); } public Map<Object, AnnotatedMember> getInjectables() { if (!_collected) { collectAll(); } return _injectables; }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> required, apply wrapper name: note, MUST be done after * annotations are merged. */ if (_config.isEnabled(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)) { _renameWithWrappers(props); } // well, almost last: there's still ordering... _sortProperties(props); _properties = props; _collected = true; } /* /********************************************************** /* Overridable internal methods, adding members /********************************************************** */ /** * Method for collecting basic information on all fields found */ protected void _addFields(Map<String, POJOPropertyBuilder> props) { final AnnotationIntrospector ai = _annotationIntrospector; /* 28-Mar-2013, tatu: For deserialization we may also want to remove * final fields, as often they won't make very good mutators... * (although, maybe surprisingly, JVM _can_ force setting of such fields!) */ final boolean pruneFinalFields = !_forSerialization && !_config.isEnabled(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS); final boolean transientAsIgnoral = _config.isEnabled(MapperFeature.PROPAGATE_TRANSIENT_MARKER); for (AnnotatedField f : _classDef.fields()) { String implName = (ai == null) ? null : ai.findImplicitPropertyName(f); if (implName == null) { implName = f.getName(); } PropertyName pn; if (ai == null) { pn = null; } else if (_forSerialization) { /* 18-Aug-2011, tatu: As per existing unit tests, we should only * use serialization annotation (@JsonSerializer) when serializing * fields, and similarly for deserialize-only annotations... so * no fallbacks in this particular case. */ pn = ai.findNameForSerialization(f); } else { pn = ai.findNameForDeserialization(f); } boolean nameExplicit = (pn != null); if (nameExplicit && pn.isEmpty()) { // empty String meaning "use default name", here just means "same as field name" pn = _propNameFromSimple(implName); name

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Visible()) { it.remove(); continue; } // Otherwise, check ignorals if (prop.anyIgnorals()) { // first: if one or more ignorals, and no explicit markers, remove the whole thing if (!prop.isExplicitlyIncluded()) { it.remove(); _collectIgnorals(prop.getName()); continue; } // otherwise just remove ones marked to be ignored prop.removeIgnored(); if (!_forSerialization && !prop.couldDeserialize()) { _collectIgnorals(prop.getName()); } } } } /** * Method called to further get rid of unwanted individual accessors, * based on read/write settings and rules for "pulling in" accessors * (or not). */ protected void _removeUnwantedAccessor(Map<String, POJOPropertyBuilder> props) { final boolean inferMutators = _config.isEnabled(MapperFeature.INFER_PROPERTY_MUTATORS); Iterator<POJOPropertyBuilder> it = props.values().iterator(); while (it.hasNext()) { POJOPropertyBuilder prop = it.next(); prop.removeNonVisible(inferMutators); } } /** * Helper method called to add explicitly ignored properties to a list * of known ignored properties; this helps in proper reporting of * errors. */ private void _collectIgnorals(String name) { if (!_forSerialization) { if (_ignoredPropertyNames == null) { _ignoredPropertyNames = new HashSet<String>(); } _ignoredPropertyNames.add(name); } } /* /********************************************************** /* Internal methods; renaming properties /********************************************************** */ protected void _renameProperties(Map<String, POJOPropertyBuilder> props) { // With renaming need to do in phases: first, find properties to rename Iterator<Map.Entry<String,POJOPropertyBuilder>> it = props.entrySet().iterator(); LinkedList<POJOPropertyBuilder> renamed = null; while (it.hasNext()) { Map.Entry<String, POJOPropertyBuilder> entry = it.next(); POJOPropertyBuilder prop = entry.getValue(); Collection<PropertyName> l = prop.findExplicitNames(); // no explicit names? Implicit one

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; @JacksonStdImpl public final class StringDeserializer extends StdScalarDeserializer<String> { private static final long serialVersionUID = 1L; /** * @since 2.2 */ public final static StringDeserializer instance = new StringDeserializer(); public StringDeserializer() { super(String.class); } // since 2.6, slightly faster lookups for this very common type @Override public boolean isCachable() { return true; } @Override public String deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken curr = jp.getCurrentToken(); if (curr == JsonToken.VALUE_STRING) { return jp.getText(); } // Issue#381 if (curr == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final String parsed = _parseString(jp, ctxt); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'String' value but there was more than a single value in the array"); } return parsed; } // [JACKSON-330]: need to gracefully handle byte[] data, as base64 if (curr == JsonToken.VALUE_EMBEDDED_OBJECT) { Object ob = jp.getEmbeddedObject(); if (ob == null) { return null; } if (ob instanceof byte[]) { return Base64Variants.getDefaultVariant().encode((byte[]) ob, false); } // otherwise, try conversion using toString()... return ob.toString(); } // allow coercions for other scalar types String text = jp.getValueAsString(); if (text != null) {

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> * TypeFactory, use of this method adds order-dependency for registrations. * * @since 2.0 */ public TypeFactory getTypeFactory(); public boolean isEnabled(MapperFeature f); public boolean isEnabled(DeserializationFeature f); public boolean isEnabled(SerializationFeature f); public boolean isEnabled(JsonFactory.Feature f); public boolean isEnabled(JsonParser.Feature f); public boolean isEnabled(JsonGenerator.Feature f); /* /********************************************************** /* Handler registration; serializers/deserializers /********************************************************** */ /** * Method that module can use to register additional deserializers to use for * handling types. * * @param d Object that can be called to find deserializer for types supported * by module (null returned for non-supported types) */ public void addDeserializers(Deserializers d); /** * Method that module can use to register additional deserializers to use for * handling Map key values (which are separate from value deserializers because * they are always serialized from String values) */ public void addKeyDeserializers(KeyDeserializers s); /** * Method that module can use to register additional serializers to use for * handling types. * * @param s Object that can be called to find serializer for types supported * by module (null returned for non-supported types) */ public void addSerializers(Serializers s); /** * Method that module can use to register additional serializers to use for * handling Map key values (which are separate from value serializers because * they must write <code>JsonToken.FIELD_NAME</code> instead of String value). */ public void addKeySerializers(Serializers s); /* /********************************************************** /* Handler registration; other /********************************************************** */ /** * Method that module can use to register additional modifier objects to * customize configuration and construction of bean deserializers. * * @param mod Modifier to register */ public void addBeanDeserializerModifier(BeanDeserializerModifier mod); /** * Method that module can use to register additional modifier objects to * customize configuration and construction of bean serializers. * * @param mod Modifier to register */ public void addBeanSerializerModifier(BeanSerializerModifier mod); /** * Method that module can use to register

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>1 Primary type to consider * @param type2 Secondary type to consider * * @since 2.2 */ public JavaType moreSpecificType(JavaType type1, JavaType type2) { if (type1 == null) { return type2; } if (type2 == null) { return type1; } Class<?> raw1 = type1.getRawClass(); Class<?> raw2 = type2.getRawClass(); if (raw1 == raw2) { return type1; } // TODO: maybe try sub-classing, to retain generic types? if (raw1.isAssignableFrom(raw2)) { return type2; } return type1; } /* /********************************************************** /* Public factory methods /********************************************************** */ public JavaType constructType(Type type) { return _constructType(type, null); } public JavaType constructType(Type type, TypeBindings bindings) { return _constructType(type, bindings); } public JavaType constructType(TypeReference<?> typeRef) { return _constructType(typeRef.getType(), null); } public JavaType constructType(Type type, Class<?> context) { TypeBindings b = (context == null) ? null : new TypeBindings(this, context); return _constructType(type, b); } public JavaType constructType(Type type, JavaType context) { TypeBindings b = (context == null) ? null : new TypeBindings(this, context); return _constructType(type, b); } /** * Factory method that can be used if type information is passed * as Java typing returned from <code>getGenericXxx</code> methods * (usually for a return or argument type). */ protected JavaType _constructType(Type type, TypeBindings context) { JavaType resultType; // simple class? if (type instanceof Class<?>) { resultType = _fromClass((Class<?>) type, context); } // But if not, need to start resolving. else if (type instanceof ParameterizedType) { resultType = _fromParamType((ParameterizedType) type, context); } else if (type instanceof JavaType) { // [Issue#1

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> builder.getValueInstantiator().getFromObjectArguments(ctxt.getConfig()); final boolean isConcrete = !beanDesc.getType().isAbstract(); // Things specified as "ok to ignore"? [JACKSON-77] AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); boolean ignoreAny = false; { Boolean B = intr.findIgnoreUnknownProperties(beanDesc.getClassInfo()); if (B != null) { ignoreAny = B.booleanValue(); builder.setIgnoreUnknownProperties(ignoreAny); } } // Or explicit/implicit definitions? Set<String> ignored = ArrayBuilders.arrayToSet(intr.findPropertiesToIgnore(beanDesc.getClassInfo(), false)); for (String propName : ignored) { builder.addIgnorable(propName); } // Also, do we have a fallback "any" setter? AnnotatedMethod anySetter = beanDesc.findAnySetter(); if (anySetter != null) { builder.setAnySetter(constructAnySetter(ctxt, beanDesc, anySetter)); } // NOTE: we do NOT add @JsonIgnore'd properties into blocked ones if there's any-setter // Implicit ones via @JsonIgnore and equivalent? if (anySetter == null) { Collection<String> ignored2 = beanDesc.getIgnoredPropertyNames(); if (ignored2 != null) { for (String propName : ignored2) { // allow ignoral of similarly named JSON property, but do not force; // latter means NOT adding this to 'ignored': builder.addIgnorable(propName); } } } final boolean useGettersAsSetters = (ctxt.isEnabled(MapperFeature.USE_GETTERS_AS_SETTERS) && ctxt.isEnabled(MapperFeature.AUTO_DETECT_GETTERS)); // Ok: let's then filter out property definitions List<BeanPropertyDefinition> propDefs = filterBeanProps(ctxt, beanDesc, builder, beanDesc.findProperties(), ignored); // After which we can let custom code change the set if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { propDefs = mod.updateProperties(ctxt.getConfig(), beanDesc, propDefs); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> && (cp instanceof CreatorProperty)) { cprop = (CreatorProperty) cp; break; } } } if (cprop == null) { throw ctxt.mappingException("Could not find creator property with name '%s' (in class %s)", name, beanDesc.getBeanClass().getName()); } if (prop != null) { cprop.setFallbackSetter(prop); } prop = cprop; builder.addCreatorProperty(cprop); continue; } if (prop != null) { Class<?>[] views = propDef.findViews(); if (views == null) { // one more twist: if default inclusion disabled, need to force empty set of views if (!ctxt.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION)) { views = NO_VIEWS; } } // one more thing before adding to builder: copy any metadata prop.setViews(views); builder.addProperty(prop); } } } /** * Helper method called to filter out explicit ignored properties, * as well as properties that have "ignorable types". * Note that this will not remove properties that have no * setters. */ protected List<BeanPropertyDefinition> filterBeanProps(DeserializationContext ctxt, BeanDescription beanDesc, BeanDeserializerBuilder builder, List<BeanPropertyDefinition> propDefsIn, Set<String> ignored) throws JsonMappingException { ArrayList<BeanPropertyDefinition> result = new ArrayList<BeanPropertyDefinition>( Math.max(4, propDefsIn.size())); HashMap<Class<?>,Boolean> ignoredTypes = new HashMap<Class<?>,Boolean>(); // These are all valid setters, but we do need to introspect bit more for (BeanPropertyDefinition property : propDefsIn) { String name = property.getName(); if (ignored.contains(name)) { // explicit ignoral using @JsonIgnoreProperties needs to block entries continue; } if (!property.hasConstructorParameter()) { // never skip constructor params Class<?> rawPropertyType = null; if (property.hasSetter()) { rawPropertyType = property.getSetter().getRawParameterType(0); } else if (property.hasField()) { rawPropertyType = property.getField().getRawType(); }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> /** * Method needed to ensure that {@link ObjectMapper#copy} will work * properly; specifically, that caches are cleared, but settings * will otherwise remain identical; and that no sharing of state * occurs. * * @since 2.5 */ public DefaultSerializerProvider copy() { throw new IllegalStateException("DefaultSerializerProvider sub-class not overriding copy()"); } /* /********************************************************** /* Extended API: methods that ObjectMapper will call /********************************************************** */ /** * Overridable method, used to create a non-blueprint instances from the blueprint. * This is needed to retain state during serialization. */ public abstract DefaultSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf); /** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * for serializing given value, using serializers that * this provider has access to (via caching and/or creating new serializers * as need be). */ public void serializeValue(JsonGenerator gen, Object value) throws IOException { if (value == null) { _serializeNull(gen); return; } Class<?> cls = value.getClass(); // true, since we do want to cache root-level typed serializers (ditto for null property) final JsonSerializer<Object> ser = findTypedValueSerializer(cls, true, null); // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _config.findRootName(value.getClass()); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.isEmpty()) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-empty that it is enabled wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName.getSimpleName()); } try { ser.serialize(value, gen, this); if (

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // As per [JACKSON-99], pass IOException and subtypes as-is throw ioe; } catch (Exception e) { // but wrap RuntimeExceptions, to get path information String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectMapper} and {@link ObjectWriter} * for serializing given value (assumed to be of specified root type, * instead of runtime type of value), * using serializers that * this provider has access to (via caching and/or creating new serializers * as need be), * * @param rootType Type to use for locating serializer to use, instead of actual * runtime type. Must be actual type, or one of its super types */ public void serializeValue(JsonGenerator gen, Object value, JavaType rootType) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if (!rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } // root value, not reached via property: JsonSerializer<Object> ser = findTypedValueSerializer(rootType, true, null); // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _config.findRootName(value.getClass()); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.isEmpty()) { wrap = false; } else { // [JACKSON-764] // empty String means explicitly disabled; non-empty that it is enabled wrap = true;

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> gen.writeStartObject(); gen.writeFieldName(rootName.getSimpleName()); } try { ser.serialize(value, gen, this); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectWriter} * for serializing given value (assumed to be of specified root type, * instead of runtime type of value), when it may know specific * {@link JsonSerializer} to use. * * @param rootType Type to use for locating serializer to use, instead of actual * runtime type, if no serializer is passed * @param ser Root Serializer to use, if not null * * @since 2.1 */ public void serializeValue(JsonGenerator gen, Object value, JavaType rootType, JsonSerializer<Object> ser) throws IOException { if (value == null) { _serializeNull(gen); return; } // Let's ensure types are compatible at this point if ((rootType != null) && !rootType.getRawClass().isAssignableFrom(value.getClass())) { _reportIncompatibleRootType(value, rootType); } // root value, not reached via property: if (ser == null) { ser = findTypedValueSerializer(rootType, true, null); } // Ok: should we wrap result in an additional property ("root name")? final boolean wrap; PropertyName rootName = _config.getFullRootName(); if (rootName == null) { // not explicitly specified // [JACKSON-163] wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = (rootType == null) ? _config.findRootName(value.getClass()) : _config.findRootName(root

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>getFullRootName(); if (rootName == null) { wrap = _config.isEnabled(SerializationFeature.WRAP_ROOT_VALUE); if (wrap) { gen.writeStartObject(); PropertyName pname = _config.findRootName(value.getClass()); gen.writeFieldName(pname.simpleAsEncoded(_config)); } } else if (rootName.isEmpty()) { wrap = false; } else { wrap = true; gen.writeStartObject(); gen.writeFieldName(rootName.getSimpleName()); } try { valueSer.serializeWithType(value, gen, this, typeSer); if (wrap) { gen.writeEndObject(); } } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * @deprecated since 2.6; remove from 2.7 or later */ @Deprecated public void serializePolymorphic(JsonGenerator gen, Object value, TypeSerializer typeSer) throws IOException { JavaType t = (value == null) ? null : _config.constructType(value.getClass()); serializePolymorphic(gen, value, t, null, typeSer); } /** * Helper method called when root value to serialize is null * * @since 2.3 */ protected void _serializeNull(JsonGenerator gen) throws IOException { JsonSerializer<Object> ser = getDefaultNullValueSerializer(); try { ser.serialize(null, gen, this); } catch (IOException ioe) { // no wrapping for IO (and derived) throw ioe; } catch (Exception e) { // but others do need to be, to get path etc String msg = e.getMessage(); if (msg == null) { msg = "[no message for "+e.getClass().getName()+"]"; } throw new JsonMappingException(msg, e); } } /** * The method to be called by {@link ObjectMapper}

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Generators.get(i); if (gen.canUseFor(generatorType)) { generator = gen; break; } } } if (generator == null) { generator = generatorType.newForSerialization(this); _objectIdGenerators.add(generator); } WritableObjectId oid = new WritableObjectId(generator); _seenObjectIds.put(forPojo, oid); return oid; } /** * Overridable helper method used for creating {@link java.util.Map} * used for storing mappings from serializable objects to their * Object Ids. * * @since 2.3 */ protected Map<Object,WritableObjectId> _createObjectIdMap() { /* 06-Aug-2013, tatu: We may actually want to use equality, * instead of identity... so: */ if (isEnabled(SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID)) { return new HashMap<Object,WritableObjectId>(); } return new IdentityHashMap<Object,WritableObjectId>(); } /* /********************************************************** /* Factory method impls /********************************************************** */ @Override public JsonSerializer<Object> serializerInstance(Annotated annotated, Object serDef) throws JsonMappingException { if (serDef == null) { return null; } JsonSerializer<?> ser; if (serDef instanceof JsonSerializer) { ser = (JsonSerializer<?>) serDef; } else { /* Alas, there's no way to force return type of "either class * X or Y" -- need to throw an exception after the fact */ if (!(serDef instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector returned serializer definition of type " +serDef.getClass().getName()+"; expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> serClass = (Class<?>)serDef; // there are some known "no class" markers to consider too: if (serClass == JsonSerializer.None.class || ClassUtil.isBogusClass(serClass)) { return null; } if (!JsonSerializer.class.isAssignableFrom(serClass)) { throw new IllegalStateException("AnnotationIntrospector returned Class " +serClass.getName()+"; expected Class<JsonSerializer

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> * @since 2.6 */ public abstract JsonSerializer<?> _withResolved(BeanProperty prop, Boolean unwrapSingle); @Override public JsonSerializer<?> createContextual(SerializerProvider provider, BeanProperty property) throws JsonMappingException { Boolean unwrapSingle = null; // First: if we have a property, may have property-annotation overrides if (property != null) { final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); JsonFormat.Value format = property.findFormatOverrides(intr); if (format != null) { unwrapSingle = format.getFeature(JsonFormat.Feature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED); if (unwrapSingle != _unwrapSingle) { return _withResolved(property, unwrapSingle); } } } return this; } // NOTE: as of 2.5, sub-classes SHOULD override (in 2.4 and before, was final), // at least if they can provide access to actual size of value and use `writeStartArray()` // variant that passes size of array to output, which is helpful with some data formats @Override public void serialize(T value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { if (hasSingleElement(value)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public final void serializeWithType(T value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { // note: let's NOT consider [JACKSON-805] here; gets too complicated, and probably just won't work typeSer.writeTypePrefixForArray(value, gen); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); serializeContents(value, gen, provider);

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> */ @Override public abstract void serialize(T value, JsonGenerator gen, SerializerProvider serializers) throws IOException; /* /********************************************************** /* Helper methods /********************************************************** */ protected boolean _asTimestamp(SerializerProvider serializers) { if (_useTimestamp != null) { return _useTimestamp.booleanValue(); } if (_customFormat == null) { if (serializers != null) { return serializers.isEnabled(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); } // 12-Jun-2014, tatu: Is it legal not to have provider? Was NPE:ing earlier so leave a check throw new IllegalArgumentException("Null SerializerProvider passed for "+handledType().getName()); } return false; } protected void _acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint, boolean asNumber) throws JsonMappingException { if (asNumber) { JsonIntegerFormatVisitor v2 = visitor.expectIntegerFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.LONG); v2.format(JsonValueFormat.UTC_MILLISEC); } } else { JsonStringFormatVisitor v2 = visitor.expectStringFormat(typeHint); if (v2 != null) { v2.format(JsonValueFormat.DATE_TIME); } } } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> {@link #canCreateFromObjectWith()} returns true, * this method may return null . */ public AnnotatedWithParams getWithArgsCreator() { return null; } /** * If an incomplete creator was found, this is the first parameter that * needs further annotation to help make the creator complete. */ public AnnotatedParameter getIncompleteParameter() { return null; } /* /********************************************************** /* Helper methods /********************************************************** */ /** * @since 2.4 (demoted from <code>StdValueInstantiator</code>) */ protected Object _createFromStringFallbacks(DeserializationContext ctxt, String value) throws IOException, JsonProcessingException { /* 28-Sep-2011, tatu: Ok this is not clean at all; but since there are legacy * systems that expect conversions in some cases, let's just add a minimal * patch (note: same could conceivably be used for numbers too). */ if (canCreateFromBoolean()) { String str = value.trim(); if ("true".equals(str)) { return createFromBoolean(ctxt, true); } if ("false".equals(str)) { return createFromBoolean(ctxt, false); } } // also, empty Strings might be accepted as null Object... if (value.length() == 0) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { return null; } } throw ctxt.mappingException("Can not instantiate value of type %s from String value ('%s'); no single-String constructor/factory method", getValueTypeDesc(), value); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>izers.getStdKeySerializer(config, rawType, true); Method m = am.getAnnotated(); if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(m); } ser = new JsonValueSerializer(m, delegate); } else { ser = StdKeySerializers.getFallbackKeySerializer(config, keyType.getRawClass()); } } } } // [databind#120]: Allow post-processing if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { ser = mod.modifyKeySerializer(config, keyType, beanDesc, ser); } } return (JsonSerializer<Object>) ser; } /** * Method called to construct a type serializer for values with given declared * base type. This is called for values other than those of bean property * types. */ @Override public TypeSerializer createTypeSerializer(SerializationConfig config, JavaType baseType) { BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); } else { subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, ac); } if (b == null) { return null; } // 10-Jun-2015, tatu: Since not created for Bean Property, no need for post-processing // wrt EXTERNAL_PROPERTY return b.buildTypeSerializer(config, baseType, subtypes); } /* /********************************************************** /* Additional API for other core classes /********************************************************** */ protected abstract Iterable<Serializers> customSerializers(); /* /********************************************************** /* Overridable secondary serializer accessor methods /********************************************************** */

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>getAnnotationIntrospector().findFilterId((Annotated)beanDesc.getClassInfo()); } /** * Helper method to check whether global settings and/or class * annotations for the bean class indicate that static typing * (declared types) should be used for properties. * (instead of dynamic runtime types). * * @since 2.1 (earlier had variant with additional 'property' parameter) */ protected boolean usesStaticTyping(SerializationConfig config, BeanDescription beanDesc, TypeSerializer typeSer) { /* 16-Aug-2010, tatu: If there is a (value) type serializer, we can not force * static typing; that would make it impossible to handle expected subtypes */ if (typeSer != null) { return false; } AnnotationIntrospector intr = config.getAnnotationIntrospector(); JsonSerialize.Typing t = intr.findSerializationTyping(beanDesc.getClassInfo()); if (t != null && t != JsonSerialize.Typing.DEFAULT_TYPING) { return (t == JsonSerialize.Typing.STATIC); } return config.isEnabled(MapperFeature.USE_STATIC_TYPING); } protected Class<?> _verifyAsClass(Object src, String methodName, Class<?> noneClass) { if (src == null) { return null; } if (!(src instanceof Class)) { throw new IllegalStateException("AnnotationIntrospector."+methodName+"() returned value of type "+src.getClass().getName()+": expected type JsonSerializer or Class<JsonSerializer> instead"); } Class<?> cls = (Class<?>) src; if (cls == noneClass || ClassUtil.isBogusClass(cls)) { return null; } return cls; } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> pp; } /* /********************************************************** /* JsonParser initialization /********************************************************** */ /** * Method called by {@link ObjectMapper} and {@link ObjectWriter} * to modify those {@link com.fasterxml.jackson.core.JsonGenerator.Feature} settings * that have been configured via this config instance. * * @since 2.5 */ public void initialize(JsonGenerator g) { if (SerializationFeature.INDENT_OUTPUT.enabledIn(_serFeatures)) { // but do not override an explicitly set one if (g.getPrettyPrinter() == null) { PrettyPrinter pp = constructDefaultPrettyPrinter(); if (pp != null) { g.setPrettyPrinter(pp); } } } @SuppressWarnings("deprecation") boolean useBigDec = SerializationFeature.WRITE_BIGDECIMAL_AS_PLAIN.enabledIn(_serFeatures); if ((_generatorFeaturesToChange != 0) || useBigDec) { int orig = g.getFeatureMask(); int newFlags = (orig & ~_generatorFeaturesToChange) | _generatorFeatures; // although deprecated, needs to be supported for now if (useBigDec) { newFlags |= JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN.getMask(); } if (orig != newFlags) { g.setFeatureMask(newFlags); } } } /* /********************************************************** /* MapperConfig implementation/overrides /********************************************************** */ @Override public boolean useRootWrapping() { if (_rootName != null) { // empty String disables wrapping; non-empty enables return !_rootName.isEmpty(); } return isEnabled(SerializationFeature.WRAP_ROOT_VALUE); } @Override public AnnotationIntrospector getAnnotationIntrospector() { if (isEnabled(MapperFeature.USE_ANNOTATIONS)) { return super.getAnnotationIntrospector(); } return AnnotationIntrospector.nopInstance(); } /** * Accessor for getting bean description that only contains class * annotations: useful if no getter/setter/creator information is needed. */ @Override public BeanDescription introspectClassAnnotations(JavaType type) { return getClassIntrospector().forClassAnnotations(this, type, this); }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> /** * Accessor for getting bean description that only contains immediate class * annotations: ones from the class, and its direct mix-in, if any, but * not from super types. */ @Override public BeanDescription introspectDirectClassAnnotations(JavaType type) { return getClassIntrospector().forDirectClassAnnotations(this, type, this); } @Override public VisibilityChecker<?> getDefaultVisibilityChecker() { VisibilityChecker<?> vchecker = super.getDefaultVisibilityChecker(); if (!isEnabled(MapperFeature.AUTO_DETECT_GETTERS)) { vchecker = vchecker.withGetterVisibility(Visibility.NONE); } // then global overrides (disabling) if (!isEnabled(MapperFeature.AUTO_DETECT_IS_GETTERS)) { vchecker = vchecker.withIsGetterVisibility(Visibility.NONE); } if (!isEnabled(MapperFeature.AUTO_DETECT_FIELDS)) { vchecker = vchecker.withFieldVisibility(Visibility.NONE); } return vchecker; } /* /********************************************************** /* Configuration: other /********************************************************** */ public final boolean isEnabled(SerializationFeature f) { return (_serFeatures & f.getMask()) != 0; } /** * Accessor method that first checks if we have any overrides * for feature, and only if not, checks state of passed-in * factory. * * @since 2.5 */ public final boolean isEnabled(JsonGenerator.Feature f, JsonFactory factory) { int mask = f.getMask(); if ((_generatorFeaturesToChange & mask) != 0) { return (_generatorFeatures & f.getMask()) != 0; } return factory.isEnabled(f); } /** * "Bulk" access method for checking that all features specified by * mask are enabled. * * @since 2.3 */ public final boolean hasSerializationFeatures(int featureMask) { return (_serFeatures & featureMask) == featureMask; } public final int getSerializationFeatures() { return _serFeatures; } public JsonInclude.Include getSerializationInclusion() { if (_serializationInclusion != null) { return _serializationInclusion; } return JsonInclude.Include.ALWAYS;

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> PropertyMetadata(req, desc, index, defaultValue); } return req ? STD_REQUIRED : STD_OPTIONAL; } /** * Minor optimization: let's canonicalize back to placeholders in cases * where there is no real data to consider */ protected Object readResolve() { if (_description == null && _index == null && _defaultValue == null) { if (_required == null) { return STD_REQUIRED_OR_OPTIONAL; } return _required.booleanValue() ? STD_REQUIRED : STD_OPTIONAL; } return this; } public PropertyMetadata withDescription(String desc) { return new PropertyMetadata(_required, desc, _index, _defaultValue); } public PropertyMetadata withDefaultValue(String def) { if ((def == null) || def.isEmpty()) { if (_defaultValue == null) { return this; } def = null; } else if (_defaultValue.equals(def)) { return this; } return new PropertyMetadata(_required, _description, _index, def); } public PropertyMetadata withIndex(Integer index) { return new PropertyMetadata(_required, _description, index, _defaultValue); } public PropertyMetadata withRequired(Boolean b) { if (b == null) { if (_required == null) { return this; } } else { if (_required != null && _required.booleanValue() == b.booleanValue()) { return this; } } return new PropertyMetadata(b, _description, _index, _defaultValue); } /* /********************************************************** /* Accessors /********************************************************** */ public String getDescription() { return _description; } /** * @since 2.5 */ public String getDefaultValue() { return _defaultValue; } /** * @deprecated Since 2.6: typo in name, use {@link #hasDefaultValue()} instead. */ @Deprecated public boolean hasDefuaultValue() { return hasDefaultValue(); } /** * Accessor for determining whether property has declared "default value", * which may be used by extension modules. * * @since 2.6 */ public boolean hasDefaultValue() { return (_defaultValue != null); } public boolean isRequired() { return (_required != null) &&

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>propertyAcc, null); if (incl != null) { suppressableValue = incl; } } if (ser == null) { ser = _valueSerializer; } // [databind#124]: May have a content converter ser = findConvertingContentSerializer(provider, property, ser); if (ser == null) { // 30-Sep-2012, tatu: One more thing -- if explicit content type is annotated, // we can consider it a static case as well. // 20-Aug-2013, tatu: Need to avoid trying to access serializer for java.lang.Object tho if ((_valueTypeIsStatic && _valueType.getRawClass() != Object.class) || hasContentTypeAnnotation(provider, property)) { ser = provider.findValueSerializer(_valueType, property); } } else { ser = provider.handleSecondaryContextualization(ser, property); } if (keySer == null) { keySer = _keySerializer; } if (keySer == null) { keySer = provider.findKeySerializer(_keyType, property); } else { keySer = provider.handleSecondaryContextualization(keySer, property); } HashSet<String> ignored = _ignoredEntries; boolean sortKeys = false; if (intr != null && propertyAcc != null) { String[] moreToIgnore = intr.findPropertiesToIgnore(propertyAcc, true); if (moreToIgnore != null) { ignored = (ignored == null) ? new HashSet<String>() : new HashSet<String>(ignored); for (String str : moreToIgnore) { ignored.add(str); } } Boolean b = intr.findSerializationSortAlphabetically(propertyAcc); sortKeys = (b != null) && b.booleanValue(); } MapSerializer mser = withResolved(property, keySer, ser, ignored, sortKeys); if (suppressableValue != _suppressableValue) { mser = mser.withContentInclusion(suppressableValue); } // [databind#307]: allow filtering if (property != null) { AnnotatedMember m = property.getMember(); if (m != null) { Object filter

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Id = intr.findFilterId(m); if (filterId != null) { mser = mser.withFilterId(filterId); } } } return mser; } /* /********************************************************** /* Accessors /********************************************************** */ @Override public JavaType getContentType() { return _valueType; } @Override public JsonSerializer<?> getContentSerializer() { return _valueSerializer; } @Override public boolean isEmpty(SerializerProvider prov, Map<?,?> value) { return (value == null) || value.isEmpty(); } @Override public boolean hasSingleElement(Map<?,?> value) { return (value.size() == 1); } /* /********************************************************** /* Extended API /********************************************************** */ /** * Accessor for currently assigned key serializer. Note that * this may return null during construction of <code>MapSerializer</code>: * depedencies are resolved during {@link #createContextual} method * (which can be overridden by custom implementations), but for some * dynamic types, it is possible that serializer is only resolved * during actual serialization. * * @since 2.0 */ public JsonSerializer<?> getKeySerializer() { return _keySerializer; } /* /********************************************************** /* JsonSerializer implementation /********************************************************** */ @Override public void serialize(Map<?,?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.writeStartObject(); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); if (!value.isEmpty()) { Object suppressableValue = _suppressableValue; if (suppressableValue == JsonInclude.Include.ALWAYS) { suppressableValue = null; } else if (suppressableValue == null) { if (!provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES)) { suppressableValue = JsonInclude.Include.NON_NULL; } } if (_sortKeys || provider.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)) { value = _orderEntries(value); } if (_filterId != null) { serializeFilteredFields(value, gen, provider, findProperty

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Filter(provider, _filterId, value), suppressableValue); } else if (suppressableValue != null) { serializeOptionalFields(value, gen, provider, suppressableValue); } else if (_valueSerializer != null) { serializeFieldsUsing(value, gen, provider, _valueSerializer); } else { serializeFields(value, gen, provider); } } gen.writeEndObject(); } @Override public void serializeWithType(Map<?,?> value, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { typeSer.writeTypePrefixForObject(value, gen); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); if (!value.isEmpty()) { Object suppressableValue = _suppressableValue; if (suppressableValue == JsonInclude.Include.ALWAYS) { suppressableValue = null; } else if (suppressableValue == null) { if (!provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES)) { suppressableValue = JsonInclude.Include.NON_NULL; } } if (_sortKeys || provider.isEnabled(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS)) { value = _orderEntries(value); } if (_filterId != null) { serializeFilteredFields(value, gen, provider, findPropertyFilter(provider, _filterId, value), suppressableValue); } else if (suppressableValue != null) { serializeOptionalFields(value, gen, provider, suppressableValue); } else if (_valueSerializer != null) { serializeFieldsUsing(value, gen, provider, _valueSerializer); } else { serializeFields(value, gen, provider); } } typeSer.writeTypeSuffixForObject(value, gen); } /* /********************************************************** /* JsonSerializer implementation /********************************************************** */ /** * Method called to serialize fields, when the value type is not statically known; * but we know that no value suppression is needed (which simplifies processing a bit) */ public void serializeFields(Map<?,?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { // If value type needs polymorphic type

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>; if (valueSer == null) { Class<?> cc = valueElem.getClass(); valueSer = serializers.serializerFor(cc); if (valueSer == null) { if (_valueType.hasGenericTypes()) { valueSer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_valueType, cc), provider); } else { valueSer = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicValueSerializers; } } // also may need to skip non-empty values: if ((suppressableValue == JsonInclude.Include.NON_EMPTY) && valueSer.isEmpty(provider, valueElem)) { continue; } } // and with that, ask filter to handle it prop.reset(keyElem, keySerializer, valueSer); try { filter.serializeAsField(valueElem, gen, provider, prop); } catch (Exception e) { String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } @Deprecated // since 2.5 public void serializeFilteredFields(Map<?,?> value, JsonGenerator gen, SerializerProvider provider, PropertyFilter filter) throws IOException { serializeFilteredFields(value, gen, provider, filter, provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES) ? null : JsonInclude.Include.NON_NULL); } /** * @since 2.5 */ protected void serializeTypedFields(Map<?,?> value, JsonGenerator gen, SerializerProvider provider, Object suppressableValue) // since 2.5 throws IOException { final HashSet<String> ignored = _ignoredEntries; PropertySerializerMap serializers = _dynamicValueSerializers; for (Map.Entry<?,?> entry : value.entrySet()) { Object keyElem = entry.getKey(); JsonSerializer<Object> keySerializer; if (keyElem == null) { keySerializer = provider.findNullKeySerializer(_keyType, _property); } else { // One twist: is entry ignorable? If so, skip if (ignored != null && ignored.contains(keyElem)) continue; keySerializer = _keySerializer; } final Object valueElem = entry.getValue(); //

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> And then value JsonSerializer<Object> valueSer; if (valueElem == null) { if (suppressableValue != null) { // all suppression include null suppression continue; } valueSer = provider.getDefaultNullValueSerializer(); } else { valueSer = _valueSerializer; Class<?> cc = valueElem.getClass(); valueSer = serializers.serializerFor(cc); if (valueSer == null) { if (_valueType.hasGenericTypes()) { valueSer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_valueType, cc), provider); } else { valueSer = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicValueSerializers; } // also may need to skip non-empty values: if ((suppressableValue == JsonInclude.Include.NON_EMPTY) && valueSer.isEmpty(provider, valueElem)) { continue; } } keySerializer.serialize(keyElem, gen, provider); try { valueSer.serializeWithType(valueElem, gen, provider, _valueTypeSerializer); } catch (Exception e) { String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } @Deprecated // since 2.5 protected void serializeTypedFields(Map<?,?> value, JsonGenerator gen, SerializerProvider provider) throws IOException { serializeTypedFields(value, gen, provider, provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES) ? null : JsonInclude.Include.NON_NULL); } /* /********************************************************** /* Schema related functionality /********************************************************** */ @Override public JsonNode getSchema(SerializerProvider provider, Type typeHint) { ObjectNode o = createSchemaNode("object", true); //(ryan) even though it's possible to statically determine the "value" type of the map, // there's no way to statically determine the keys, so the "Entries" can't be determined. return o; } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { JsonMapFormatVisitor v2 = (visitor == null) ? null : visitor.expectMap

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.JsonParser.NumberType; import com.fasterxml.jackson.core.io.NumberInput; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.introspect.AnnotatedMember; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.util.ClassUtil; import com.fasterxml.jackson.databind.util.Converter; /** * Base class for common deserializers. Contains shared * base functionality for dealing with primitive values, such * as (re)parsing from String. */ public abstract class StdDeserializer<T> extends JsonDeserializer<T> implements java.io.Serializable { private static final long serialVersionUID = 1L; /** * Bitmask that covers {@link DeserializationFeature#USE_BIG_INTEGER_FOR_INTS} * and {@link DeserializationFeature#USE_LONG_FOR_INTS}, used for more efficient * cheks when coercing integral values for untyped deserialization. * * @since 2.6 */ protected final static int F_MASK_INT_COERCIONS = DeserializationFeature.USE_BIG_INTEGER_FOR_INTS.getMask() | DeserializationFeature.USE_LONG_FOR_INTS.getMask(); /** * Type of values this deserializer handles: sometimes * exact types, other time most specific supertype of * types deserializer handles (which may be as generic * as {@link Object} in some case) */ final protected Class<?> _valueClass; protected StdDeserializer(Class<?> vc) { _valueClass = vc; } protected StdDeserializer(JavaType valueType) { _valueClass = (valueType == null) ? null : valueType.getRawClass(); } /** * Copy-constructor for sub-classes to use, most often when creating * new instances for {@link com.fasterxml.jackson.databind.deser.ContextualDeserializer}. *

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>_NULL) return false; // [JACKSON-78]: should accept ints too, (0 == false, otherwise true) if (t == JsonToken.VALUE_NUMBER_INT) { // 11-Jan-2012, tatus: May be outside of int... if (jp.getNumberType() == NumberType.INT) { return (jp.getIntValue() != 0); } return _parseBooleanFromNumber(jp, ctxt); } // And finally, let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); // [#422]: Allow aliases if ("true".equals(text) || "True".equals(text)) { return true; } if ("false".equals(text) || "False".equals(text) || text.length() == 0) { return false; } if (_hasTextualNull(text)) { return false; } throw ctxt.weirdStringException(text, _valueClass, "only \"true\" or \"false\" recognized"); } // [databind#381] if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final boolean parsed = _parseBooleanPrimitive(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'boolean' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final Boolean _parseBoolean(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken t = p.getCurrentToken(); if (t == JsonToken.VALUE_TRUE) { return Boolean.TRUE; } if (t == JsonToken.VALUE_FALSE) { return Boolean.FALSE; } // [JACKSON-78]: should accept ints too, (0 == false, otherwise true) if (

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>t == JsonToken.VALUE_NUMBER_INT) { // 11-Jan-2012, tatus: May be outside of int... if (p.getNumberType() == NumberType.INT) { return (p.getIntValue() == 0) ? Boolean.FALSE : Boolean.TRUE; } return Boolean.valueOf(_parseBooleanFromNumber(p, ctxt)); } if (t == JsonToken.VALUE_NULL) { return (Boolean) getNullValue(ctxt); } // And finally, let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { String text = p.getText().trim(); // [#422]: Allow aliases if ("true".equals(text) || "True".equals(text)) { return Boolean.TRUE; } if ("false".equals(text) || "False".equals(text)) { return Boolean.FALSE; } if (text.length() == 0) { return (Boolean) getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return (Boolean) getNullValue(ctxt); } throw ctxt.weirdStringException(text, _valueClass, "only \"true\" or \"false\" recognized"); } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Boolean parsed = _parseBoolean(p, ctxt); t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Boolean' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final boolean _parseBooleanFromNumber(JsonParser jp, DeserializationContext ctxt) throws IOException { if (jp.getNumberType() == NumberType.LONG) { return (jp.getLongValue() == 0L) ? Boolean.FALSE : Boolean.TRUE; } // no really good logic; let's

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> actually resort to textual comparison String str = jp.getText(); if ("0.0".equals(str) || "0".equals(str)) { return Boolean.FALSE; } return Boolean.TRUE; } protected Byte _parseByte(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken t = p.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT) { return p.getByteValue(); } if (t == JsonToken.VALUE_STRING) { // let's do implicit re-parse String text = p.getText().trim(); if (_hasTextualNull(text)) { return (Byte) getNullValue(ctxt); } int value; try { int len = text.length(); if (len == 0) { return (Byte) getEmptyValue(ctxt); } value = NumberInput.parseInt(text); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid Byte value"); } // So far so good: but does it fit? // as per [JACKSON-804], allow range up to 255, inclusive if (value < Byte.MIN_VALUE || value > 255) { throw ctxt.weirdStringException(text, _valueClass, "overflow, value can not be represented as 8-bit value"); } return Byte.valueOf((byte) value); } if (t == JsonToken.VALUE_NUMBER_FLOAT) { if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "Byte"); } return p.getByteValue(); } if (t == JsonToken.VALUE_NULL) { return (Byte) getNullValue(ctxt); } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Byte parsed = _parseByte(p, ctxt); t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Byte' value but there was more than a single value in the array"); } return parsed; } throw ctxt.mappingException(_valueClass, t); } protected Short _parseShort(JsonParser p, DeserializationContext ctxt) throws IOException { JsonToken t = p.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT) { return p.getShortValue(); } if (t == JsonToken.VALUE_STRING) { // let's do implicit re-parse String text = p.getText().trim(); int value; try { int len = text.length(); if (len == 0) { return (Short) getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return (Short) getNullValue(ctxt); } value = NumberInput.parseInt(text); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid Short value"); } // So far so good: but does it fit? if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { throw ctxt.weirdStringException(text, _valueClass, "overflow, value can not be represented as 16-bit value"); } return Short.valueOf((short) value); } if (t == JsonToken.VALUE_NUMBER_FLOAT) { if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "Short"); } return p.getShortValue(); } if (t == JsonToken.VALUE_NULL) { return (Short) getNullValue(ctxt); } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Short parsed = _parseShort(p, ctxt); t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> single value array for single 'Short' value but there was more than a single value in the array"); } return parsed; } throw ctxt.mappingException(_valueClass, t); } protected final short _parseShortPrimitive(JsonParser jp, DeserializationContext ctxt) throws IOException { int value = _parseIntPrimitive(jp, ctxt); // So far so good: but does it fit? if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { throw ctxt.weirdStringException(String.valueOf(value), _valueClass, "overflow, value can not be represented as 16-bit value"); } return (short) value; } protected final int _parseIntPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { return p.getIntValue(); } JsonToken t = p.getCurrentToken(); if (t == JsonToken.VALUE_STRING) { // let's do implicit re-parse String text = p.getText().trim(); if (_hasTextualNull(text)) { return 0; } try { int len = text.length(); if (len > 9) { long l = Long.parseLong(text); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw ctxt.weirdStringException(text, _valueClass, "Overflow: numeric value ("+text+") out of range of int ("+Integer.MIN_VALUE+" - "+Integer.MAX_VALUE+")"); } return (int) l; } if (len == 0) { return 0; } return NumberInput.parseInt(text); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid int value"); } } if (t == JsonToken.VALUE_NUMBER_FLOAT) { if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "int"); } return p.getValueAsInt(); } if (t == JsonToken.VALUE_NULL)

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { return 0; } if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final int parsed = _parseIntPrimitive(p, ctxt); t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'int' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final Integer _parseInteger(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { // NOTE: caller assumed to usually check VALUE_NUMBER_INT in fast path case JsonTokenId.ID_NUMBER_INT: return Integer.valueOf(p.getIntValue()); case JsonTokenId.ID_NUMBER_FLOAT: // coercing may work too if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "Integer"); } return Integer.valueOf(p.getValueAsInt()); case JsonTokenId.ID_STRING: // let's do implicit re-parse String text = p.getText().trim(); try { int len = text.length(); if (_hasTextualNull(text)) { return (Integer) getNullValue(ctxt); } if (len > 9) { long l = Long.parseLong(text); if (l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) { throw ctxt.weirdStringException(text, _valueClass, "Overflow: numeric value ("+text+") out of range of Integer ("+Integer.MIN_VALUE+" - "+Integer.MAX_VALUE+")"); } return Integer.valueOf((int) l); } if (len == 0) { return (Integer) getEmptyValue(ctxt); } return Integer.valueOf(NumberInput.parseInt(text)); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> _valueClass, "not a valid Integer value"); } case JsonTokenId.ID_NULL: return (Integer) getNullValue(ctxt); case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Integer parsed = _parseInteger(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Integer' value but there was more than a single value in the array"); } return parsed; } break; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } protected final Long _parseLong(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { // NOTE: caller assumed to usually check VALUE_NUMBER_INT in fast path case JsonTokenId.ID_NUMBER_INT: return p.getLongValue(); case JsonTokenId.ID_NUMBER_FLOAT: if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "Long"); } return p.getValueAsLong(); case JsonTokenId.ID_STRING: // let's allow Strings to be converted too // !!! 05-Jan-2009, tatu: Should we try to limit value space, JDK is too lenient? String text = p.getText().trim(); if (text.length() == 0) { return (Long) getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return (Long) getNullValue(ctxt); } try { return Long.valueOf(NumberInput.parseLong(text)); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid Long value"); case JsonTokenId.ID_NULL: return (Long) getNullValue(ctxt); case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Long parsed = _parseLong(p, ctxt); JsonToken t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Long' value but there was more than a single value in the array"); } return parsed; } break; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } protected final long _parseLongPrimitive(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_NUMBER_INT: return p.getLongValue(); case JsonTokenId.ID_NUMBER_FLOAT: if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "long"); } return p.getValueAsLong(); case JsonTokenId.ID_STRING: String text = p.getText().trim(); if (text.length() == 0 || _hasTextualNull(text)) { return 0L; } try { return NumberInput.parseLong(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid long value"); case JsonTokenId.ID_NULL: return 0L; case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final long parsed = _parseLongPrimitive(p, ctxt); JsonToken t = p.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'long' value but there was more than a single value in the array"); } return parsed; } break; } throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } protected final Float _parseFloat(JsonParser jp,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> DeserializationContext ctxt) throws IOException { // We accept couple of different types; obvious ones first: JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { // coercing should work too return jp.getFloatValue(); } // And finally, let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0) { return (Float) getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return (Float) getNullValue(ctxt); } switch (text.charAt(0)) { case 'I': if (_isPosInf(text)) { return Float.POSITIVE_INFINITY; } break; case 'N': if (_isNaN(text)) { return Float.NaN; } break; case '-': if (_isNegInf(text)) { return Float.NEGATIVE_INFINITY; } break; } try { return Float.parseFloat(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid Float value"); } if (t == JsonToken.VALUE_NULL) { return (Float) getNullValue(ctxt); } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final Float parsed = _parseFloat(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Byte' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final float _parseFloatPrimitive(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { // coercing should work too return jp.getFloatValue(); } if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0 || _hasTextualNull(text)) { return 0.0f; } switch (text.charAt(0)) { case 'I': if (_isPosInf(text)) { return Float.POSITIVE_INFINITY; } break; case 'N': if (_isNaN(text)) { return Float.NaN; } break; case '-': if (_isNegInf(text)) { return Float.NEGATIVE_INFINITY; } break; } try { return Float.parseFloat(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid float value"); } if (t == JsonToken.VALUE_NULL) { return 0.0f; } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final float parsed = _parseFloatPrimitive(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'float' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final Double _parseDouble(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { // coercing should work too return jp.getDoubleValue(); } if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0) { return (Double)

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return (Double) getNullValue(ctxt); } switch (text.charAt(0)) { case 'I': if (_isPosInf(text)) { return Double.POSITIVE_INFINITY; } break; case 'N': if (_isNaN(text)) { return Double.NaN; } break; case '-': if (_isNegInf(text)) { return Double.NEGATIVE_INFINITY; } break; } try { return parseDouble(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid Double value"); } if (t == JsonToken.VALUE_NULL) { return (Double) getNullValue(ctxt); } if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final Double parsed = _parseDouble(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Double' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected final double _parseDoublePrimitive(JsonParser jp, DeserializationContext ctxt) throws IOException { // We accept couple of different types; obvious ones first: JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT || t == JsonToken.VALUE_NUMBER_FLOAT) { // coercing should work too return jp.getDoubleValue(); } // And finally, let's allow Strings to be converted too if (t == JsonToken.VALUE_STRING) { String text = jp.getText().trim(); if (text.length() == 0 || _hasTextualNull(text)) { return 0.0; } switch (text.charAt(0)) { case 'I': if (_isPosInf(text))

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { return Double.POSITIVE_INFINITY; } break; case 'N': if (_isNaN(text)) { return Double.NaN; } break; case '-': if (_isNegInf(text)) { return Double.NEGATIVE_INFINITY; } break; } try { return parseDouble(text); } catch (IllegalArgumentException iae) { } throw ctxt.weirdStringException(text, _valueClass, "not a valid double value"); } if (t == JsonToken.VALUE_NULL) { return 0.0; } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final double parsed = _parseDoublePrimitive(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'Byte' value but there was more than a single value in the array"); } return parsed; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, t); } protected java.util.Date _parseDate(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_NUMBER_INT) { return new java.util.Date(jp.getLongValue()); } if (t == JsonToken.VALUE_NULL) { return (java.util.Date) getNullValue(ctxt); } if (t == JsonToken.VALUE_STRING) { String value = null; try { // As per [JACKSON-203], take empty Strings to mean value = jp.getText().trim(); if (value.length() == 0) { return (Date) getEmptyValue(ctxt); } if (_hasTextualNull(value)) { return (java.util.Date) getNullValue(ctxt); } return ctxt.parseDate(value); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(value, _

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>valueClass, "not a valid representation (error: "+iae.getMessage()+")"); } } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final Date parsed = _parseDate(jp, ctxt); t = jp.nextToken(); if (t != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'java.util.Date' value but there was more than a single value in the array"); } return parsed; } throw ctxt.mappingException(_valueClass, t); } /** * Helper method for encapsulating calls to low-level double value parsing; single place * just because we need a work-around that must be applied to all calls. */ protected final static double parseDouble(String numStr) throws NumberFormatException { // [JACKSON-486]: avoid some nasty float representations... but should it be MIN_NORMAL or MIN_VALUE? // for now, MIN_VALUE, since MIN_NORMAL is JDK 1.6 if (NumberInput.NASTY_SMALL_DOUBLE.equals(numStr)) { return Double.MIN_VALUE; } return Double.parseDouble(numStr); } /** * Helper method used for accessing String value, if possible, doing * necessary conversion or throwing exception as necessary. * * @since 2.1 */ protected final String _parseString(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.VALUE_STRING) { return jp.getText(); } // Issue#381 if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final String parsed = _parseString(jp, ctxt); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'String' value

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> but there was more than a single value in the array"); } return parsed; } String value = jp.getValueAsString(); if (value != null) { return value; } throw ctxt.mappingException(String.class, jp.getCurrentToken()); } /** * Helper method that may be used to support fallback for Empty String / Empty Array * non-standard representations; usually for things serialized as JSON Objects. * * @since 2.5 */ protected T _deserializeFromEmpty(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.START_ARRAY) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT)) { t = jp.nextToken(); if (t == JsonToken.END_ARRAY) { return null; } throw ctxt.mappingException(handledType(), JsonToken.START_ARRAY); } } else if (t == JsonToken.VALUE_STRING) { if (ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = jp.getText().trim(); if (str.isEmpty()) { return null; } } } throw ctxt.mappingException(handledType()); } /** * Helper method called to determine if we are seeing String value of * "null", and, further, that it should be coerced to null just like * null token. * * @since 2.3 */ protected boolean _hasTextualNull(String value) { return "null".equals(value); } protected final boolean _isNegInf(String text) { return "-Infinity".equals(text) || "-INF".equals(text); } protected final boolean _isPosInf(String text) { return "Infinity".equals(text) || "INF".equals(text); } protected final boolean _isNaN(String text) { return "NaN".equals(text); } /* /**************************************************** /* Helper methods for sub-classes, coercions /**************************************************** */ /** * Helper method called in case where an integral number is encountered, but * config settings suggest that a co

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>ercion may be needed to "upgrade" * {@link java.lang.Number} into "bigger" type like {@link java.lang.Long} or * {@link java.math.BigInteger} * * @see DeserializationFeature#USE_BIG_INTEGER_FOR_INTS * @see DeserializationFeature#USE_LONG_FOR_INTS * * @since 2.6 */ protected Object _coerceIntegral(JsonParser p, DeserializationContext ctxt) throws IOException { int feats = ctxt.getDeserializationFeatures(); if (DeserializationFeature.USE_BIG_INTEGER_FOR_INTS.enabledIn(feats)) { return p.getBigIntegerValue(); } if (DeserializationFeature.USE_LONG_FOR_INTS.enabledIn(feats)) { return p.getLongValue(); } return p.getBigIntegerValue(); // should be optimal, whatever it is } /* /**************************************************** /* Helper methods for sub-classes, resolving dependencies /**************************************************** */ /** * Helper method used to locate deserializers for properties the * type this deserializer handles contains (usually for properties of * bean types) * * @param type Type of property to deserialize * @param property Actual property object (field, method, constuctor parameter) used * for passing deserialized values; provided so deserializer can be contextualized if necessary (since 1.7) */ protected JsonDeserializer<Object> findDeserializer(DeserializationContext ctxt, JavaType type, BeanProperty property) throws JsonMappingException { return ctxt.findContextualValueDeserializer(type, property); } /** * Helper method to check whether given text refers to what looks like a clean simple * integer number, consisting of optional sign followed by a sequence of digits. */ protected final boolean _isIntNumber(String text) { final int len = text.length(); if (len > 0) { char c = text.charAt(0); // skip leading sign (plus not allowed for strict JSON numbers but...) int i = (c == '-' || c == '+') ? 1 : 0; for (; i < len; ++i) { int ch = text.charAt(i); if (ch > '9' || ch

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } private final String[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException { // [JACKSON-526]: implicit arrays from single values? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT)) { String str = jp.getText(); if (str.length() == 0) { return null; } } throw ctxt.mappingException(_valueClass); } return new String[] { (jp.getCurrentToken() == JsonToken.VALUE_NULL) ? null : _parseString(jp, ctxt) }; } /** * Contextualization is needed to see whether we can "inline" deserialization * of String values, or if we have to use separate value deserializer. */ @Override public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException { JsonDeserializer<?> deser = _elementDeserializer; // #125: May have a content converter deser = findConvertingContentDeserializer(ctxt, property, deser); JavaType type = ctxt.constructType(String.class); if (deser == null) { deser = ctxt.findContextualValueDeserializer(type, property); } else { // if directly assigned, probably not yet contextual, so: deser = ctxt.handleSecondaryContextualization(deser, property, type); } // Ok ok: if all we got is the default String deserializer, can just forget about it if (deser != null && this.isDefaultDeserializer(deser)) { deser = null; } if (_elementDeserializer != deser) { return new StringArrayDeserializer(deser); } return this; } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> some formats, * notably XML. Note, however, that while we can get String, we can't * assume that's what we use due to custom deserializer */ String value; if (jp.nextTextValue() == null) { JsonToken t = jp.getCurrentToken(); if (t == JsonToken.END_ARRAY) { break; } // Ok: no need to convert Strings, but must recognize nulls value = (t == JsonToken.VALUE_NULL) ? deser.getNullValue(ctxt) : deser.deserialize(jp, ctxt); } else { value = deser.deserialize(jp, ctxt); } result.add(value); } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /** * Helper method called when current token is not START_ARRAY. Will either * throw an exception, or try to handle value as if member of implicit * array, depending on configuration. */ private final Collection<String> handleNonArray(JsonParser jp, DeserializationContext ctxt, Collection<String> result) throws IOException { // [JACKSON-526]: implicit arrays from single values? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_collectionType.getRawClass()); } // Strings are one of "native" (intrinsic) types, so there's never type deserializer involved JsonDeserializer<String> valueDes = _valueDeserializer; JsonToken t = jp.getCurrentToken(); String value; if (t == JsonToken.VALUE_NULL) { value = (valueDes == null) ? null : valueDes.getNullValue(ctxt); } else { value = (valueDes == null) ? _parseString(jp, ctxt) : valueDes.deserialize(jp, ctxt); } result.add(value); return result; } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; import com.fasterxml.jackson.databind.ser.ContainerSerializer; @JacksonStdImpl @SuppressWarnings("serial") public class IterableSerializer extends AsArraySerializerBase<Iterable<?>> { public IterableSerializer(JavaType elemType, boolean staticTyping, TypeSerializer vts) { super(Iterable.class, elemType, staticTyping, vts, null); } public IterableSerializer(IterableSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle) { super(src, property, vts, valueSerializer, unwrapSingle); } @Override public ContainerSerializer<?> _withValueTypeSerializer(TypeSerializer vts) { return new IterableSerializer(this, _property, vts, _elementSerializer, _unwrapSingle); } @Override public IterableSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new IterableSerializer(this, property, vts, elementSerializer, unwrapSingle); } @Override public boolean isEmpty(SerializerProvider prov, Iterable<?> value) { // Not really good way to implement this, but has to do for now: return (value == null) || !value.iterator().hasNext(); } @Override public boolean hasSingleElement(Iterable<?> value) { // we can do it actually (fixed in 2.3.1) if (value != null) { Iterator<?> it = value.iterator(); if (it.hasNext()) { it.next(); if (!it.hasNext()) { return true; } } } return false; } @Override public final void serialize(Iterable<?> value, JsonGenerator gen, SerializerProvider provider)throws IOException { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>(this, objectIdWriter); } @Override public BeanSerializerBase withFilterId(Object filterId) { return new UnwrappingBeanSerializer(this, _objectIdWriter, filterId); } @Override protected BeanSerializerBase withIgnorals(String[] toIgnore) { return new UnwrappingBeanSerializer(this, toIgnore); } /** * JSON Array output can not be done if unwrapping operation is * requested; so implementation will simply return 'this'. */ @Override protected BeanSerializerBase asArraySerializer() { return this; } /* /********************************************************** /* JsonSerializer implementation that differs between impls /********************************************************** */ /** * Main serialization method that will delegate actual output to * configured * {@link BeanPropertyWriter} instances. */ @Override public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException { gen.setCurrentValue(bean); // [databind#631] if (_objectIdWriter != null) { _serializeWithObjectId(bean, gen, provider, false); return; } if (_propertyFilterId != null) { serializeFieldsFiltered(bean, gen, provider); } else { serializeFields(bean, gen, provider); } } @Override public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, TypeSerializer typeSer) throws IOException { if (provider.isEnabled(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS)) { throw new JsonMappingException("Unwrapped property requires use of type information: can not serialize without disabling `SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS`"); } gen.setCurrentValue(bean); // [databind#631] if (_objectIdWriter != null) { _serializeWithObjectId(bean, gen, provider, typeSer); return; } if (_propertyFilterId != null) { serializeFieldsFiltered(bean, gen, provider); } else { serializeFields(bean, gen, provider); } } /* /********************************************************** /* Standard methods /********************************************************** */ @Override public String toString() { return "UnwrappingBeanSerializer for "+handledType().getName(); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind; import java.io.*; import java.util.*; import static org.junit.Assert.*; import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.databind.ObjectMapper; public abstract class BaseMapTest extends BaseTest { private final static Object SINGLETON_OBJECT = new Object(); /* /********************************************************** /* Shared helper classes /********************************************************** */ /** * Simple wrapper around boolean types, usually to test value * conversions or wrapping */ protected static class BooleanWrapper { public Boolean b; @JsonCreator public BooleanWrapper(Boolean value) { b = value; } @JsonValue public Boolean value() { return b; } } protected static class IntWrapper { public int i; public IntWrapper() { } public IntWrapper(int value) { i = value; } } protected static class LongWrapper { public long l; public LongWrapper() { } public LongWrapper(long value) { l = value; } } /** * Simple wrapper around String type, usually to test value * conversions or wrapping */ protected static class StringWrapper { public String str; public StringWrapper() { } public StringWrapper(String value) { str = value; } } protected static class ObjectWrapper { private final Object object; protected ObjectWrapper(final Object object) { this.object = object; } public Object getObject() { return object; } @JsonCreator static ObjectWrapper jsonValue(final Object object) { return new ObjectWrapper(object); } } protected static class ListWrapper<T> { public List<T> list; public ListWrapper(T... values) { list = new ArrayList<T>(); for (T value : values) { list.add(value); } } } protected static class MapWrapper<K,V> { public Map<K,V> map; public MapWrapper(Map<K,V> m) { map = m; } } protected static class ArrayWrapper<T> { public T[] array; public ArrayWrapper(T[] v) { array = v

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind; import java.lang.reflect.Type; import java.util.Locale; import java.util.TimeZone; import com.fasterxml.jackson.annotation.ObjectIdGenerator; import com.fasterxml.jackson.annotation.ObjectIdResolver; import com.fasterxml.jackson.databind.cfg.HandlerInstantiator; import com.fasterxml.jackson.databind.cfg.MapperConfig; import com.fasterxml.jackson.databind.introspect.Annotated; import com.fasterxml.jackson.databind.introspect.ObjectIdInfo; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.databind.util.ClassUtil; import com.fasterxml.jackson.databind.util.Converter; /** * Shared base class for {@link DeserializationContext} and * {@link SerializerProvider}, context objects passed through data-binding * process. Designed so that some of implementations can rely on shared * aspects like access to secondary contextual objects like type factories * or handler instantiators. * * @since 2.2 */ public abstract class DatabindContext { /* /********************************************************** /* Generic config access /********************************************************** */ /** * Accessor to currently active configuration (both per-request configs * and per-mapper config). */ public abstract MapperConfig<?> getConfig(); /** * Convenience method for accessing serialization view in use (if any); equivalent to: *<pre> * getConfig().getAnnotationIntrospector(); *</pre> */ public abstract AnnotationIntrospector getAnnotationIntrospector(); /* /********************************************************** /* Access to specific config settings /********************************************************** */ /** * Convenience method for checking whether specified serialization * feature is enabled or not. * Shortcut for: *<pre> * getConfig().isEnabled(feature); *</pre> */ public final boolean isEnabled(MapperFeature feature) { return getConfig().isEnabled(feature); } /** * Convenience method for accessing serialization view in use (if any); equivalent to: *<pre> * getConfig().canOverrideAccessModifiers(); *</pre> */ public final boolean canOverrideAccessModifiers() { return getConfig().canOverrideAccessModifiers(); } /** * Access

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> First: if we have a property, may have property-annotation overrides if (property != null) { AnnotatedMember m = property.getMember(); final AnnotationIntrospector intr = provider.getAnnotationIntrospector(); if (m != null) { Object serDef = intr.findContentSerializer(m); if (serDef != null) { ser = provider.serializerInstance(m, serDef); } } JsonFormat.Value format = property.findFormatOverrides(intr); if (format != null) { unwrapSingle = format.getFeature(JsonFormat.Feature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED); } } if (ser == null) { ser = _elementSerializer; } // #124: May have a content converter ser = findConvertingContentSerializer(provider, property, ser); if (ser == null) { // 30-Sep-2012, tatu: One more thing -- if explicit content type is annotated, // we can consider it a static case as well. if (_elementType != null) { if (_staticTyping || hasContentTypeAnnotation(provider, property)) { ser = provider.findValueSerializer(_elementType, property); } } } else { ser = provider.handleSecondaryContextualization(ser, property); } return withResolved(property, vts, ser, unwrapSingle); } /* /********************************************************** /* Accessors /********************************************************** */ @Override public JavaType getContentType() { return _elementType; } @Override public JsonSerializer<?> getContentSerializer() { return _elementSerializer; } @Override public boolean isEmpty(SerializerProvider prov, Object[] value) { return (value == null) || (value.length == 0); } @Override public boolean hasSingleElement(Object[] value) { return (value.length == 1); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public final void serialize(Object[] value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.length; if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(Serialization

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.deser.std; import java.io.IOException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; public class StackTraceElementDeserializer extends StdScalarDeserializer<StackTraceElement> { private static final long serialVersionUID = 1L; public StackTraceElementDeserializer() { super(StackTraceElement.class); } @Override public StackTraceElement deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { JsonToken t = jp.getCurrentToken(); // Must get an Object if (t == JsonToken.START_OBJECT) { String className = "", methodName = "", fileName = ""; int lineNumber = -1; while ((t = jp.nextValue()) != JsonToken.END_OBJECT) { String propName = jp.getCurrentName(); if ("className".equals(propName)) { className = jp.getText(); } else if ("fileName".equals(propName)) { fileName = jp.getText(); } else if ("lineNumber".equals(propName)) { if (t.isNumeric()) { lineNumber = jp.getIntValue(); } else { throw JsonMappingException.from(jp, "Non-numeric token ("+t+") for property 'lineNumber'"); } } else if ("methodName".equals(propName)) { methodName = jp.getText(); } else if ("nativeMethod".equals(propName)) { // no setter, not passed via constructor: ignore } else { handleUnknownProperty(jp, ctxt, _valueClass, propName); } } return new StackTraceElement(className, methodName, fileName, lineNumber); } else if (t == JsonToken.START_ARRAY && ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { jp.nextToken(); final StackTraceElement value = deserialize(jp, ctxt); if (jp.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(jp, JsonToken.END_ARRAY, "Attempted to unwrap single value array for

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_START_OBJECT: case JsonTokenId.ID_FIELD_NAME: if (_mapDeserializer != null) { return _mapDeserializer.deserialize(p, ctxt); } return mapObject(p, ctxt); case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)) { return mapArrayToArray(p, ctxt); } if (_listDeserializer != null) { return _listDeserializer.deserialize(p, ctxt); } return mapArray(p, ctxt); case JsonTokenId.ID_EMBEDDED_OBJECT: return p.getEmbeddedObject(); case JsonTokenId.ID_STRING: if (_stringDeserializer != null) { return _stringDeserializer.deserialize(p, ctxt); } return p.getText(); case JsonTokenId.ID_NUMBER_INT: if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt); } /* Caller may want to get all integral values returned as {@link java.math.BigInteger}, * or {@link java.lang.Long} for consistency */ if (ctxt.hasSomeOfFeatures(F_MASK_INT_COERCIONS)) { return _coerceIntegral(p, ctxt); } return p.getNumberValue(); // should be optimal, whatever it is case JsonTokenId.ID_NUMBER_FLOAT: if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt); } /* [JACKSON-72]: need to allow overriding the behavior regarding * which type to use */ if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return p.getDecimalValue(); } return p.getDoubleValue(); case JsonTokenId.ID_TRUE: return Boolean.TRUE; case JsonTokenId.ID_FALSE: return Boolean.FALSE; case JsonTokenId.ID_NULL: // should not get this but... return null; // case JsonTokenId.ID_END_

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>ARRAY: // invalid // case JsonTokenId.ID_END_OBJECT: // invalid default: } throw ctxt.mappingException(Object.class); } @Override public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { switch (p.getCurrentTokenId()) { // First: does it look like we had type id wrapping of some kind? case JsonTokenId.ID_START_ARRAY: case JsonTokenId.ID_START_OBJECT: case JsonTokenId.ID_FIELD_NAME: /* Output can be as JSON Object, Array or scalar: no way to know * a this point: */ return typeDeserializer.deserializeTypedFromAny(p, ctxt); case JsonTokenId.ID_EMBEDDED_OBJECT: return p.getEmbeddedObject(); /* Otherwise we probably got a "native" type (ones that map * naturally and thus do not need or use type ids) */ case JsonTokenId.ID_STRING: if (_stringDeserializer != null) { return _stringDeserializer.deserialize(p, ctxt); } return p.getText(); case JsonTokenId.ID_NUMBER_INT: if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt); } // May need coercion to "bigger" types: if (ctxt.hasSomeOfFeatures(F_MASK_INT_COERCIONS)) { return _coerceIntegral(p, ctxt); } return p.getNumberValue(); // should be optimal, whatever it is case JsonTokenId.ID_NUMBER_FLOAT: if (_numberDeserializer != null) { return _numberDeserializer.deserialize(p, ctxt); } // For [JACKSON-72], see above if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return p.getDecimalValue(); } return Double.valueOf(p.getDoubleValue()); case JsonTokenId.ID_TRUE: return Boolean.TRUE; case JsonTokenId.ID_FALSE: return Boolean.FALSE; case JsonTokenId.ID_NULL: // should not get this far really but... return null; default: }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> ptr = 0; do { Object value = deserialize(jp, ctxt); if (ptr >= values.length) { values = buffer.appendCompletedChunk(values); ptr = 0; } values[ptr++] = value; } while (jp.nextToken() != JsonToken.END_ARRAY); return buffer.completeAndClearBuffer(values, ptr); } /* /********************************************************** /* Separate "vanilla" implementation for common case of /* no custom deserializer overrides /********************************************************** */ @JacksonStdImpl public static class Vanilla extends StdDeserializer<Object> { private static final long serialVersionUID = 1L; public final static Vanilla std = new Vanilla(); public Vanilla() { super(Object.class); } @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_START_OBJECT: { JsonToken t = p.nextToken(); if (t == JsonToken.END_OBJECT) { return new LinkedHashMap<String,Object>(2); } } case JsonTokenId.ID_FIELD_NAME: return mapObject(p, ctxt); case JsonTokenId.ID_START_ARRAY: { JsonToken t = p.nextToken(); if (t == JsonToken.END_ARRAY) { // and empty one too if (ctxt.isEnabled(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)) { return NO_OBJECTS; } return new ArrayList<Object>(2); } } if (ctxt.isEnabled(DeserializationFeature.USE_JAVA_ARRAY_FOR_JSON_ARRAY)) { return mapArrayToArray(p, ctxt); } return mapArray(p, ctxt); case JsonTokenId.ID_EMBEDDED_OBJECT: return p.getEmbeddedObject(); case JsonTokenId.ID_STRING: return p.getText(); case JsonTokenId.ID_NUMBER_INT: if (ctxt.hasSomeOfFeatures(F_MASK_INT_COERCIONS)) { return _coerceIntegral(p, ctxt); } return p.getNumberValue(); // should be optimal, whatever it is case Json

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>TokenId.ID_NUMBER_FLOAT: if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return p.getDecimalValue(); } return Double.valueOf(p.getDoubleValue()); case JsonTokenId.ID_TRUE: return Boolean.TRUE; case JsonTokenId.ID_FALSE: return Boolean.FALSE; case JsonTokenId.ID_NULL: // should not get this but... return null; //case JsonTokenId.ID_END_ARRAY: // invalid //case JsonTokenId.ID_END_OBJECT: // invalid default: throw ctxt.mappingException(Object.class); } } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { switch (jp.getCurrentTokenId()) { case JsonTokenId.ID_START_ARRAY: case JsonTokenId.ID_START_OBJECT: case JsonTokenId.ID_FIELD_NAME: return typeDeserializer.deserializeTypedFromAny(jp, ctxt); case JsonTokenId.ID_STRING: return jp.getText(); case JsonTokenId.ID_NUMBER_INT: if (ctxt.isEnabled(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)) { return jp.getBigIntegerValue(); } return jp.getNumberValue(); case JsonTokenId.ID_NUMBER_FLOAT: if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return jp.getDecimalValue(); } return Double.valueOf(jp.getDoubleValue()); case JsonTokenId.ID_TRUE: return Boolean.TRUE; case JsonTokenId.ID_FALSE: return Boolean.FALSE; case JsonTokenId.ID_EMBEDDED_OBJECT: return jp.getEmbeddedObject(); case JsonTokenId.ID_NULL: // should not get this far really but... return null; default: throw ctxt.mappingException(Object.class); } } protected Object mapArray(JsonParser jp, DeserializationContext ctxt) throws IOException { Object value = deserialize(jp, ctxt); if (jp.nextToken() == JsonToken.END_ARRAY) { ArrayList<Object> l

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, property, ser, unwrapSingle); } /* /********************************************************** /* Simple accessors /********************************************************** */ @Override public JavaType getContentType() { return VALUE_TYPE; } @Override public JsonSerializer<?> getContentSerializer() { return _elementSerializer; } @Override public boolean isEmpty(SerializerProvider prov, String[] value) { return (value == null) || (value.length == 0); } @Override public boolean hasSingleElement(String[] value) { return (value.length == 1); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public final void serialize(String[] value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.length; if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(len); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public void serializeContents(String[] value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.length; if (len == 0) { return; } if (_elementSerializer != null) { serializeContentsSlow(value, gen, provider, _elementSerializer); return; } for (int i = 0; i < len; ++i) { String str = value[i]; if (str == null) { gen.writeNull(); } else { gen.writeString(value[i]); } } } private void serializeContentsSlow(String[] value, JsonGenerator gen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException { for (int i = 0, len = value.length; i < len; ++i) { String str = value[i]; if (str == null) { provider.defaultSerializeNull(gen); } else { ser.serialize(value[i], gen, provider); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> /* /********************************************************** /* Helper methods /********************************************************** */ protected boolean _isIgnorable(Annotated a) { JsonIgnore ann = _findAnnotation(a, JsonIgnore.class); return (ann != null && ann.value()); } protected Class<?> _classIfExplicit(Class<?> cls) { if (cls == null || ClassUtil.isBogusClass(cls)) { return null; } return cls; } protected Class<?> _classIfExplicit(Class<?> cls, Class<?> implicit) { cls = _classIfExplicit(cls); return (cls == null || cls == implicit) ? null : cls; } protected PropertyName _propertyName(String localName, String namespace) { if (localName.isEmpty()) { return PropertyName.USE_DEFAULT; } if (namespace == null || namespace.isEmpty()) { return PropertyName.construct(localName); } return PropertyName.construct(localName, namespace); } /** * Helper method called to construct and initialize instance of {@link TypeResolverBuilder} * if given annotated element indicates one is needed. */ @SuppressWarnings("deprecation") protected TypeResolverBuilder<?> _findTypeResolver(MapperConfig<?> config, Annotated ann, JavaType baseType) { // First: maybe we have explicit type resolver? TypeResolverBuilder<?> b; JsonTypeInfo info = _findAnnotation(ann, JsonTypeInfo.class); JsonTypeResolver resAnn = _findAnnotation(ann, JsonTypeResolver.class); if (resAnn != null) { if (info == null) { return null; } /* let's not try to force access override (would need to pass * settings through if we did, since that's not doable on some * platforms) */ b = config.typeResolverBuilderInstance(ann, resAnn.value()); } else { // if not, use standard one, if indicated by annotations if (info == null) { return null; } // bit special; must return 'marker' to block use of default typing: if (info.use() == JsonTypeInfo.Id.NONE) { return _constructNoTypeResolverBuilder(); } b = _constructStdTypeResolverBuilder(); } // Does it define a

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> custom type id resolver? JsonTypeIdResolver idResInfo = _findAnnotation(ann, JsonTypeIdResolver.class); TypeIdResolver idRes = (idResInfo == null) ? null : config.typeIdResolverInstance(ann, idResInfo.value()); if (idRes != null) { // [JACKSON-359] idRes.init(baseType); } b = b.init(info.use(), idRes); /* 13-Aug-2011, tatu: One complication wrt [JACKSON-453]; external id * only works for properties; so if declared for a Class, we will need * to map it to "PROPERTY" instead of "EXTERNAL_PROPERTY" */ JsonTypeInfo.As inclusion = info.include(); if (inclusion == JsonTypeInfo.As.EXTERNAL_PROPERTY && (ann instanceof AnnotatedClass)) { inclusion = JsonTypeInfo.As.PROPERTY; } b = b.inclusion(inclusion); b = b.typeProperty(info.property()); Class<?> defaultImpl = info.defaultImpl(); // 08-Dec-2014, tatu: To deprecated `JsonTypeInfo.None` we need to use other placeholder(s); // and since `java.util.Void` has other purpose (to indicate "deser as null"), we'll instead // use `JsonTypeInfo.class` itself. But any annotation type will actually do, as they have no // valid use (can not instantiate as default) if (defaultImpl != JsonTypeInfo.None.class && !defaultImpl.isAnnotation()) { b = b.defaultImpl(defaultImpl); } b = b.typeIdVisibility(info.visible()); return b; } /** * Helper method for constructing standard {@link TypeResolverBuilder} * implementation. */ protected StdTypeResolverBuilder _constructStdTypeResolverBuilder() { return new StdTypeResolverBuilder(); } /** * Helper method for dealing with "no type info" marker; can't be null * (as it'd be replaced by default typing) */ protected StdTypeResolverBuilder _constructNoTypeResolverBuilder() { return StdTypeResolverBuilder.noTypeInfoBuilder(); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> to use: convenience method for *<pre> * getConfig().getLocale(); *</pre> */ @Override public Locale getLocale() { return _config.getLocale(); } /** * Method for accessing default TimeZone to use: convenience method for *<pre> * getConfig().getTimeZone(); *</pre> */ @Override public TimeZone getTimeZone() { return _config.getTimeZone(); } /* /********************************************************** /* Access to per-call state, like generic attributes (2.3+) /********************************************************** */ @Override public Object getAttribute(Object key) { return _attributes.getAttribute(key); } @Override public DeserializationContext setAttribute(Object key, Object value) { _attributes = _attributes.withPerCallAttribute(key, value); return this; } /** * Accessor to {@link JavaType} of currently contextualized * {@link ContextualDeserializer}, if any. * This is sometimes useful for generic {@link JsonDeserializer}s that * do not get passed (or do not retain) type information when being * constructed: happens for example for deserializers constructed * from annotations. * * @since 2.5 * * @return Type of {@link ContextualDeserializer} being contextualized, * if process is on-going; null if not. */ public JavaType getContextualType() { return (_currentType == null) ? null : _currentType.value(); } /* /********************************************************** /* Public API, config setting accessors /********************************************************** */ /** * Method for getting current {@link DeserializerFactory}. */ public DeserializerFactory getFactory() { return _factory; } /** * Convenience method for checking whether specified on/off * feature is enabled */ public final boolean isEnabled(DeserializationFeature feat) { /* 03-Dec-2010, tatu: minor shortcut; since this is called quite often, * let's use a local copy of feature settings: */ return (_featureFlags & feat.getMask()) != 0; } /** * Bulk access method for getting the bit mask of all {@link DeserializationFeature}s * that are enabled

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> boolean handleUnknownProperty(JsonParser p, JsonDeserializer<?> deser, Object instanceOrClass, String propName) throws IOException, JsonProcessingException { LinkedNode<DeserializationProblemHandler> h = _config.getProblemHandlers(); if (h != null) { while (h != null) { // Can bail out if it's handled if (h.value().handleUnknownProperty(this, p, deser, instanceOrClass, propName)) { return true; } h = h.next(); } } return false; } /** * Helper method for reporting a problem with unhandled unknown exception * * @param instanceOrClass Either value being populated (if one has been * instantiated), or Class that indicates type that would be (or * have been) instantiated * @param deser Deserializer that had the problem, if called by deserializer * (or on behalf of one) */ public void reportUnknownProperty(Object instanceOrClass, String fieldName, JsonDeserializer<?> deser) throws JsonMappingException { if (!isEnabled(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)) { return; } // Do we know properties that are expected instead? Collection<Object> propIds = (deser == null) ? null : deser.getKnownPropertyNames(); throw UnrecognizedPropertyException.from(_parser, instanceOrClass, fieldName, propIds); } /* /********************************************************** /* Methods for constructing exceptions /********************************************************** */ /** * Helper method for constructing generic mapping exception for specified type */ public JsonMappingException mappingException(Class<?> targetClass) { return mappingException(targetClass, _parser.getCurrentToken()); } public JsonMappingException mappingException(Class<?> targetClass, JsonToken token) { return JsonMappingException.from(_parser, String.format("Can not deserialize instance of %s out of %s token", _calcName(targetClass), token)); } /** * Helper method for constructing generic mapping exception with specified * message and current location information */ public JsonMappingException mappingException(String message) { return JsonMappingException.from(getParser(), message); } /** * Helper method for constructing generic mapping exception with specified * message and current location information * *

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>reference through this property. * Method can choose to indicate an error by throwing {@link JsonMappingException}; * fully handle serialization (and return true); or indicate that it should be * serialized normally (return false). *<p> * Default implementation will throw {@link JsonMappingException} if * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled; * or return <code>false</code> if it is disabled. * * @return True if method fully handled self-referential value; false if not (caller * is to handle it) or {@link JsonMappingException} if there is no way handle it */ protected boolean _handleSelfReference(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser) throws JsonMappingException { if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES) && !ser.usesObjectId()) { // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling // object id; this may be the case for BeanSerializers at least. // 13-Feb-2014, tatu: another possible ok case: custom serializer (something // OTHER than {@link BeanSerializerBase} if (ser instanceof BeanSerializerBase) { throw new JsonMappingException("Direct self-reference leading to cycle"); } } return false; } @Override public String toString() { StringBuilder sb = new StringBuilder(40); sb.append("property '").append(getName()).append("' ("); if (_accessorMethod != null) { sb.append("via method ").append(_accessorMethod.getDeclaringClass().getName()).append("#").append(_accessorMethod.getName()); } else if (_field != null) { sb.append("field \"").append(_field.getDeclaringClass().getName()).append("#").append(_field.getName()); } else { sb.append("virtual"); } if (_serializer == null) { sb.append(", no static serializer"); } else { sb.append(", static serializer of type "+_serializer.getClass().getName()); } sb.append(')'); return sb.toString(); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>1, c2); } static int _badChar(String uuidStr, int index, char c) { throw new NumberFormatException("Non-hex character '"+c+"', not valid character for a UUID String" +"' (value 0x"+Integer.toHexString(c)+") for UUID String \""+uuidStr+"\""); } private UUID _fromBytes(byte[] bytes, DeserializationContext ctxt) throws IOException { if (bytes.length != 16) { ctxt.mappingException("Can only construct UUIDs from byte[16]; got %d bytes", bytes.length); } return new UUID(_long(bytes, 0), _long(bytes, 8)); } private static long _long(byte[] b, int offset) { long l1 = ((long) _int(b, offset)) << 32; long l2 = _int(b, offset+4); // faster to just do it than check if it has sign l2 = (l2 << 32) >>> 32; // to get rid of sign return l1 | l2; } private static int _int(byte[] b, int offset) { return (b[offset] << 24) | ((b[offset+1] & 0xFF) << 16) | ((b[offset+2] & 0xFF) << 8) | (b[offset+3] & 0xFF); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> @Override public final T getNullValue(DeserializationContext ctxt) throws JsonMappingException { if (_primitive && ctxt.isEnabled(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)) { throw ctxt.mappingException( "Can not map JSON null into type %s (set DeserializationConfig.DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES to 'false' to allow)", handledType().toString()); } return _nullValue; } @Override @Deprecated // remove in 2.7 public final T getNullValue() { return _nullValue; } } /* /********************************************************** /* Then primitive/wrapper types /********************************************************** */ @JacksonStdImpl public final static class BooleanDeserializer extends PrimitiveOrWrapperDeserializer<Boolean> { private static final long serialVersionUID = 1L; final static BooleanDeserializer primitiveInstance = new BooleanDeserializer(Boolean.TYPE, Boolean.FALSE); final static BooleanDeserializer wrapperInstance = new BooleanDeserializer(Boolean.class, null); public BooleanDeserializer(Class<Boolean> cls, Boolean nvl) { super(cls, nvl); } @Override public Boolean deserialize(JsonParser j, DeserializationContext ctxt) throws IOException { return _parseBoolean(j, ctxt); } // 1.6: since we can never have type info ("natural type"; String, Boolean, Integer, Double): // (is it an error to even call this version?) @Override public Boolean deserializeWithType(JsonParser p, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { return _parseBoolean(p, ctxt); } } @JacksonStdImpl public static class ByteDeserializer extends PrimitiveOrWrapperDeserializer<Byte> { private static final long serialVersionUID = 1L; final static ByteDeserializer primitiveInstance = new ByteDeserializer(Byte.TYPE, (byte) 0); final static ByteDeserializer wrapperInstance = new ByteDeserializer(Byte.class, null); public ByteDeserializer(Class<Byte> cls, Byte nvl) { super(cls, nvl); } @Override public Byte deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { return _parseByte(p, ctxt); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> @JacksonStdImpl public static class ShortDeserializer extends PrimitiveOrWrapperDeserializer<Short> { private static final long serialVersionUID = 1L; final static ShortDeserializer primitiveInstance = new ShortDeserializer(Short.TYPE, Short.valueOf((short)0)); final static ShortDeserializer wrapperInstance = new ShortDeserializer(Short.class, null); public ShortDeserializer(Class<Short> cls, Short nvl) { super(cls, nvl); } @Override public Short deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { return _parseShort(jp, ctxt); } } @JacksonStdImpl public static class CharacterDeserializer extends PrimitiveOrWrapperDeserializer<Character> { private static final long serialVersionUID = 1L; final static CharacterDeserializer primitiveInstance = new CharacterDeserializer(Character.TYPE, '\0'); final static CharacterDeserializer wrapperInstance = new CharacterDeserializer(Character.class, null); public CharacterDeserializer(Class<Character> cls, Character nvl) { super(cls, nvl); } @Override public Character deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_NUMBER_INT: // ok iff ascii value int value = p.getIntValue(); if (value >= 0 && value <= 0xFFFF) { return Character.valueOf((char) value); } break; case JsonTokenId.ID_STRING: // this is the usual type // But does it have to be exactly one char? String text = p.getText(); if (text.length() == 1) { return Character.valueOf(text.charAt(0)); } // actually, empty should become null? if (text.length() == 0) { return (Character) getEmptyValue(ctxt); } break; case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Character C = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, Json

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> This is why {@link #deserializeWithType} must be overridden. */ @SuppressWarnings("serial") @JacksonStdImpl public static class NumberDeserializer extends StdScalarDeserializer<Object> { public final static NumberDeserializer instance = new NumberDeserializer(); public NumberDeserializer() { super(Number.class); } @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_NUMBER_INT: if (ctxt.hasSomeOfFeatures(F_MASK_INT_COERCIONS)) { return _coerceIntegral(p, ctxt); } return p.getNumberValue(); case JsonTokenId.ID_NUMBER_FLOAT: if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return p.getDecimalValue(); } return Double.valueOf(p.getDoubleValue()); case JsonTokenId.ID_STRING: /* Textual values are more difficult... not parsing itself, but figuring * out 'minimal' type to use */ String text = p.getText().trim(); if (text.length() == 0) { return getEmptyValue(ctxt); } if (_hasTextualNull(text)) { return getNullValue(ctxt); } if (_isPosInf(text)) { return Double.POSITIVE_INFINITY; } if (_isNegInf(text)) { return Double.NEGATIVE_INFINITY; } if (_isNaN(text)) { return Double.NaN; } try { if (!_isIntNumber(text)) { if (ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) { return new BigDecimal(text); } return new Double(text); } if (ctxt.isEnabled(DeserializationFeature.USE_BIG_INTEGER_FOR_INTS)) { return new BigInteger(text); } long value = Long.parseLong(text); if (!ctxt.isEnabled(DeserializationFeature.USE_LONG_FOR_INTS)) { if (value <= Integer.MAX_VALUE && value >= Integer.MIN_VALUE) { return Integer.valueOf((int) value); } } return Long.valueOf(value

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid number"); } case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final Object value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single '" + _valueClass.getName() + "' value but there was more than a single value in the array" ); } return value; } break; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } /** * As mentioned in class Javadoc, there is additional complexity in * handling potentially mixed type information here. Because of this, * we must actually check for "raw" integers and doubles first, before * calling type deserializer. */ @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { switch (jp.getCurrentTokenId()) { case JsonTokenId.ID_NUMBER_INT: case JsonTokenId.ID_NUMBER_FLOAT: case JsonTokenId.ID_STRING: // can not point to type information: hence must be non-typed (int/double) return deserialize(jp, ctxt); } return typeDeserializer.deserializeTypedFromScalar(jp, ctxt); } } /* /********************************************************** /* And then bit more complicated (but non-structured) number /* types /********************************************************** */ /** * This is bit trickier to implement efficiently, while avoiding * overflow problems. */ @SuppressWarnings("serial") @JacksonStdImpl public static class BigIntegerDeserializer extends StdScalarDeserializer<BigInteger> { public final static BigIntegerDeserializer instance = new BigIntegerDeserializer(); public BigIntegerDeserializer() { super(BigInteger.class); } @SuppressWarnings("incomplete-switch") @Override public BigInteger deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId())

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { case JsonTokenId.ID_NUMBER_INT: switch (p.getNumberType()) { case INT: case LONG: case BIG_INTEGER: return p.getBigIntegerValue(); } break; case JsonTokenId.ID_NUMBER_FLOAT: if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) { _failDoubleToIntCoercion(p, ctxt, "java.math.BigInteger"); } return p.getDecimalValue().toBigInteger(); case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final BigInteger value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'BigInteger' value but there was more than a single value in the array" ); } return value; } break; case JsonTokenId.ID_STRING: // let's do implicit re-parse String text = p.getText().trim(); if (text.length() == 0) { return null; } try { return new BigInteger(text); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid representation"); } } // String is ok too, can easily convert; otherwise, no can do: throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } } @SuppressWarnings("serial") @JacksonStdImpl public static class BigDecimalDeserializer extends StdScalarDeserializer<BigDecimal> { public final static BigDecimalDeserializer instance = new BigDecimalDeserializer(); public BigDecimalDeserializer() { super(BigDecimal.class); } @Override public BigDecimal deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_NUMBER_INT: case JsonTokenId.ID_NUMBER_FLOAT: return p.getDecimalValue(); case JsonTokenId.ID_STRING: String text = p.getText().trim(); if (text.length() == 0)

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> { return null; } try { return new BigDecimal(text); } catch (IllegalArgumentException iae) { throw ctxt.weirdStringException(text, _valueClass, "not a valid representation"); } case JsonTokenId.ID_START_ARRAY: if (ctxt.isEnabled(DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS)) { p.nextToken(); final BigDecimal value = deserialize(p, ctxt); if (p.nextToken() != JsonToken.END_ARRAY) { throw ctxt.wrongTokenException(p, JsonToken.END_ARRAY, "Attempted to unwrap single value array for single 'BigDecimal' value but there was more than a single value in the array" ); } return value; } break; } // Otherwise, no can do: throw ctxt.mappingException(_valueClass, p.getCurrentToken()); } } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> are not beans... if (!isPotentialBeanType(type.getRawClass())) { // 03-Aug-2012, tatu: Except we do need to allow serializers for Enums, // as per [Issue#24] if (!type.isEnumType()) { return null; } } return constructBeanSerializer(prov, beanDesc); } /** * Method called to create a type information serializer for values of given * non-container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param baseType Declared type to use as the base type for type information serializer * * @return Type serializer to use for property values, if one is needed; null if not. */ public TypeSerializer findPropertyTypeSerializer(JavaType baseType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, accessor, baseType); TypeSerializer typeSer; // Defaulting: if no annotations on member, check value class if (b == null) { typeSer = createTypeSerializer(config, baseType); } else { Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass( config, accessor, baseType); typeSer = b.buildTypeSerializer(config, baseType, subtypes); } return typeSer; } /** * Method called to create a type information serializer for values of given * container property * if one is needed. If not needed (no polymorphic handling configured), should * return null. * * @param containerType Declared type of the container to use as the base type for type information serializer * * @return Type serializer to use for property value contents, if one is needed; null if not. */ public TypeSerializer findPropertyContentTypeSerializer(JavaType containerType, SerializationConfig config, AnnotatedMember accessor) throws JsonMappingException { JavaType contentType = containerType.getContentType(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, accessor, containerType); TypeSerializer typeSer; // Defaulting: if no annotations on member, check value class if (b == null) { typeSer = createTypeSerializer(config, contentType); } else { Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByClass(config, accessor, contentType); typeSer = b.buildTypeSerializer(config, contentType, subtypes); } return typeSer; } /* /********************************************************** /* Overridable non-public factory methods /********************************************************** */ /** * Method called to construct serializer for serializing specified bean type. * * @since 2.1 */ @SuppressWarnings("unchecked") protected JsonSerializer<Object> constructBeanSerializer(SerializerProvider prov, BeanDescription beanDesc) throws JsonMappingException { // 13-Oct-2010, tatu: quick sanity check: never try to create bean serializer for plain Object // 05-Jul-2012, tatu: ... but we should be able to just return "unknown type" serializer, right? if (beanDesc.getBeanClass() == Object.class) { return prov.getUnknownTypeSerializer(Object.class); // throw new IllegalArgumentException("Can not create bean serializer for Object.class"); } final SerializationConfig config = prov.getConfig(); BeanSerializerBuilder builder = constructBeanSerializerBuilder(beanDesc); builder.setConfig(config); // First: any detectable (auto-detect, annotations) properties to serialize? List<BeanPropertyWriter> props = findBeanProperties(prov, beanDesc, builder); if (props == null) { props = new ArrayList<BeanPropertyWriter>(); } else { props = removeOverlappingTypeIds(prov, beanDesc, builder, props); } // [databind#638]: Allow injection of "virtual" properties: prov.getAnnotationIntrospector().findAndAddVirtualProperties(config, beanDesc.getClassInfo(), props); // [JACKSON-440] Need to allow modification bean properties to serialize: if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { props = mod.changeProperties(config, bean

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Desc, props); } } // Any properties to suppress? props = filterBeanProperties(config, beanDesc, props); // [JACKSON-440] Need to allow reordering of properties to serialize if (_factoryConfig.hasSerializerModifiers()) { for (BeanSerializerModifier mod : _factoryConfig.serializerModifiers()) { props = mod.orderProperties(config, beanDesc, props); } } /* And if Object Id is needed, some preparation for that as well: better * do before view handling, mostly for the custom id case which needs * access to a property */ builder.setObjectIdWriter(constructObjectIdHandler(prov, beanDesc, props)); builder.setProperties(props); builder.setFilterId(findFilterId(config, beanDesc)); AnnotatedMember anyGetter = beanDesc.findAnyGetter(); if (anyGetter != null) { if (config.canOverrideAccessModifiers()) { anyGetter.fixAccess(); } JavaType type = anyGetter.getType(beanDesc.bindingsForBeanType()); // copied from BasicSerializerFactory.buildMapSerializer(): boolean staticTyping = config.isEnabled(MapperFeature.USE_STATIC_TYPING); JavaType valueType = type.getContentType(); TypeSerializer typeSer = createTypeSerializer(config, valueType); // last 2 nulls; don't know key, value serializers (yet) // 23-Feb-2015, tatu: As per [#705], need to support custom serializers JsonSerializer<?> anySer = findSerializerFromAnnotation(prov, anyGetter); if (anySer == null) { // TODO: support '@JsonIgnoreProperties' with any setter? anySer = MapSerializer.construct(/* ignored props*/ null, type, staticTyping, typeSer, null, null, /*filterId*/ null); } // TODO: can we find full PropertyName? PropertyName name = PropertyName.construct(anyGetter.getName()); BeanProperty.Std anyProp = new BeanProperty.Std(name, valueType, null, beanDesc.getClassAnnotations(), anyGetter, PropertyMetadata.STD_OPTIONAL); builder.setAnyGetter(new AnyGetterWriter(anyProp, anyGetter, anySer)); } // Next: need to gather view

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>BeanPropertyDefinition> properties = beanDesc.findProperties(); final SerializationConfig config = prov.getConfig(); // [JACKSON-429]: ignore specified types removeIgnorableTypes(config, beanDesc, properties); // and possibly remove ones without matching mutator... if (config.isEnabled(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS)) { removeSetterlessGetters(config, beanDesc, properties); } // nothing? can't proceed (caller may or may not throw an exception) if (properties.isEmpty()) { return null; } // null is for value type serializer, which we don't have access to from here (ditto for bean prop) boolean staticTyping = usesStaticTyping(config, beanDesc, null); PropertyBuilder pb = constructPropertyBuilder(config, beanDesc); ArrayList<BeanPropertyWriter> result = new ArrayList<BeanPropertyWriter>(properties.size()); TypeBindings typeBind = beanDesc.bindingsForBeanType(); for (BeanPropertyDefinition property : properties) { final AnnotatedMember accessor = property.getAccessor(); // [JACKSON-762]: type id? Requires special handling: if (property.isTypeId()) { if (accessor != null) { // only add if we can access... but otherwise? if (config.canOverrideAccessModifiers()) { accessor.fixAccess(); } builder.setTypeId(accessor); } continue; } // [JACKSON-235]: suppress writing of back references AnnotationIntrospector.ReferenceProperty refType = property.findReferenceType(); if (refType != null && refType.isBackReference()) { continue; } if (accessor instanceof AnnotatedMethod) { result.add(_constructWriter(prov, property, typeBind, pb, staticTyping, (AnnotatedMethod) accessor)); } else { result.add(_constructWriter(prov, property, typeBind, pb, staticTyping, (AnnotatedField) accessor)); } } return result; } /* /********************************************************** /* Overridable non-public methods for manipulating bean properties /********************************************************** */ /** * Overridable method that can filter out properties. Default implementation * checks annotations class may have. */ protected List<Bean

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>PropertyWriter> filterBeanProperties(SerializationConfig config, BeanDescription beanDesc, List<BeanPropertyWriter> props) { AnnotationIntrospector intr = config.getAnnotationIntrospector(); AnnotatedClass ac = beanDesc.getClassInfo(); String[] ignored = intr.findPropertiesToIgnore(ac, true); if (ignored != null && ignored.length > 0) { HashSet<String> ignoredSet = ArrayBuilders.arrayToSet(ignored); Iterator<BeanPropertyWriter> it = props.iterator(); while (it.hasNext()) { if (ignoredSet.contains(it.next().getName())) { it.remove(); } } } return props; } /** * Method called to handle view information for constructed serializer, * based on bean property writers. *<p> * Note that this method is designed to be overridden by sub-classes * if they want to provide custom view handling. As such it is not * considered an internal implementation detail, and will be supported * as part of API going forward. */ protected void processViews(SerializationConfig config, BeanSerializerBuilder builder) { // [JACKSON-232]: whether non-annotated fields are included by default or not is configurable List<BeanPropertyWriter> props = builder.getProperties(); boolean includeByDefault = config.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION); final int propCount = props.size(); int viewsFound = 0; BeanPropertyWriter[] filtered = new BeanPropertyWriter[propCount]; // Simple: view information is stored within individual writers, need to combine: for (int i = 0; i < propCount; ++i) { BeanPropertyWriter bpw = props.get(i); Class<?>[] views = bpw.getViews(); if (views == null) { // no view info? include or exclude by default? if (includeByDefault) { filtered[i] = bpw; } } else { ++viewsFound; filtered[i] = constructFilteredBeanWriter(bpw, views); } } // minor optimization: if no view info, include-by-default, can leave out filtering info altogether: if (includeByDefault && viewsFound == 0) { return;

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> return _annotationIntrospector.findReferenceType(member); } }); } @Override public boolean isTypeId() { Boolean b = fromMemberAnnotations(new WithMember<Boolean>() { @Override public Boolean withMember(AnnotatedMember member) { return _annotationIntrospector.isTypeId(member); } }); return (b != null) && b.booleanValue(); } @Override public PropertyMetadata getMetadata() { final Boolean b = _findRequired(); final String desc = _findDescription(); final Integer idx = _findIndex(); final String def = _findDefaultValue(); if (b == null && idx == null && def == null) { return (desc == null) ? PropertyMetadata.STD_REQUIRED_OR_OPTIONAL : PropertyMetadata.STD_REQUIRED_OR_OPTIONAL.withDescription(desc); } return PropertyMetadata.construct(b.booleanValue(), desc, idx, def); } protected Boolean _findRequired() { Boolean b = fromMemberAnnotations(new WithMember<Boolean>() { @Override public Boolean withMember(AnnotatedMember member) { return _annotationIntrospector.hasRequiredMarker(member); } }); return b; } protected String _findDescription() { return fromMemberAnnotations(new WithMember<String>() { @Override public String withMember(AnnotatedMember member) { return _annotationIntrospector.findPropertyDescription(member); } }); } protected Integer _findIndex() { return fromMemberAnnotations(new WithMember<Integer>() { @Override public Integer withMember(AnnotatedMember member) { return _annotationIntrospector.findPropertyIndex(member); } }); } protected String _findDefaultValue() { return fromMemberAnnotations(new WithMember<String>() { @Override public String withMember(AnnotatedMember member) { return _annotationIntrospector.findPropertyDefaultValue(member); } }); } @Override public ObjectIdInfo findObjectIdInfo() { return fromMemberAnnotations(new WithMember<ObjectIdInfo>() { @Override public ObjectIdInfo withMember(AnnotatedMember member) { ObjectIdInfo info = _annotationIntrospector.findObjectIdInfo(member); if (info != null) { info = _annotationIntrospector

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>ObjectId(bean, gen, provider, typeSer); return; } String typeStr = (_typeId == null) ? null : _customTypeId(bean); if (typeStr == null) { typeSer.writeTypePrefixForArray(bean, gen); } else { typeSer.writeCustomTypePrefixForArray(bean, gen, typeStr); } serializeAsArray(bean, gen, provider); if (typeStr == null) { typeSer.writeTypeSuffixForArray(bean, gen); } else { typeSer.writeCustomTypeSuffixForArray(bean, gen, typeStr); } } /** * Main serialization method that will delegate actual output to * configured * {@link BeanPropertyWriter} instances. */ @Override public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException { if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) && hasSingleElement(provider)) { serializeAsArray(bean, gen, provider); return; } /* note: it is assumed here that limitations (type id, object id, * any getter, filtering) have already been checked; so code here * is trivial. */ gen.writeStartArray(); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(bean); serializeAsArray(bean, gen, provider); gen.writeEndArray(); } /* /********************************************************** /* Field serialization methods /********************************************************** */ private boolean hasSingleElement(SerializerProvider provider) { final BeanPropertyWriter[] props; if (_filteredProps != null && provider.getActiveView() != null) { props = _filteredProps; } else { props = _props; } return props.length == 1; } protected final void serializeAsArray(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException { final BeanPropertyWriter[] props; if (_filteredProps != null && provider.getActiveView() != null) { props = _filteredProps; } else { props = _props; } int i = 0; try { for (final int len = props.length

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> FromStringDeserializer<?> deser = FromStringDeserializer.findDeserializer(Currency.class); return new StdKeyDeserializer(TYPE_CURRENCY, raw, deser); } else { return null; } return new StdKeyDeserializer(kind, raw); } @Override public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException, JsonProcessingException { if (key == null) { // is this even legal call? return null; } try { Object result = _parse(key, ctxt); if (result != null) { return result; } } catch (Exception re) { throw ctxt.weirdKeyException(_keyClass, key, "not a valid representation: "+re.getMessage()); } if (_keyClass.isEnum() && ctxt.getConfig().isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { return null; } throw ctxt.weirdKeyException(_keyClass, key, "not a valid representation"); } public Class<?> getKeyClass() { return _keyClass; } protected Object _parse(String key, DeserializationContext ctxt) throws Exception { switch (_kind) { case TYPE_BOOLEAN: if ("true".equals(key)) { return Boolean.TRUE; } if ("false".equals(key)) { return Boolean.FALSE; } throw ctxt.weirdKeyException(_keyClass, key, "value not 'true' or 'false'"); case TYPE_BYTE: { int value = _parseInt(key); // as per [JACKSON-804], allow range up to 255, inclusive if (value < Byte.MIN_VALUE || value > 255) { throw ctxt.weirdKeyException(_keyClass, key, "overflow, value can not be represented as 8-bit value"); } return Byte.valueOf((byte) value); } case TYPE_SHORT: { int value = _parseInt(key); if (value < Short.MIN_VALUE || value > Short.MAX_VALUE) { throw ctxt.weirdKeyException(_keyClass, key, "overflow, value can not be represented as 16-bit value"); } return Short.valueOf((

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> @JacksonStdImpl final static class EnumKD extends StdKeyDeserializer { private static final long serialVersionUID = 1L; protected final EnumResolver _resolver; protected final AnnotatedMethod _factory; protected EnumKD(EnumResolver er, AnnotatedMethod factory) { super(-1, er.getEnumClass()); _resolver = er; _factory = factory; } @Override public Object _parse(String key, DeserializationContext ctxt) throws JsonMappingException { if (_factory != null) { try { return _factory.call1(key); } catch (Exception e) { ClassUtil.unwrapAndThrowAsIAE(e); } } Enum<?> e = _resolver.findEnum(key); if (e == null && !ctxt.getConfig().isEnabled(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL)) { throw ctxt.weirdKeyException(_keyClass, key, "not one of values for Enum class"); } return e; } } /** * Key deserializer that calls a single-string-arg constructor * to instantiate desired key type. */ final static class StringCtorKeyDeserializer extends StdKeyDeserializer { private static final long serialVersionUID = 1L; protected final Constructor<?> _ctor; public StringCtorKeyDeserializer(Constructor<?> ctor) { super(-1, ctor.getDeclaringClass()); _ctor = ctor; } @Override public Object _parse(String key, DeserializationContext ctxt) throws Exception { return _ctor.newInstance(key); } } /** * Key deserializer that calls a static no-args factory method * to instantiate desired key type. */ final static class StringFactoryKeyDeserializer extends StdKeyDeserializer { private static final long serialVersionUID = 1L; final Method _factoryMethod; public StringFactoryKeyDeserializer(Method fm) { super(-1, fm.getDeclaringClass()); _factoryMethod = fm; } @Override public Object _parse(String key, DeserializationContext ctxt) throws Exception { return _factoryMethod.invoke(null, key); } } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>(value, gen); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); if (_valueSerializer != null) { serializeUsing(value, gen, provider, _valueSerializer); } else { serializeDynamic(value, gen, provider); } typeSer.writeTypeSuffixForObject(value, gen); } protected void serializeDynamic(Map.Entry<?, ?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { final JsonSerializer<Object> keySerializer = _keySerializer; final boolean skipNulls = !provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES); final TypeSerializer vts = _valueTypeSerializer; PropertySerializerMap serializers = _dynamicValueSerializers; Object valueElem = value.getValue(); Object keyElem = value.getKey(); if (keyElem == null) { provider.findNullKeySerializer(_keyType, _property).serialize(null, jgen, provider); } else { // [JACKSON-314] skip entries with null values? if (skipNulls && valueElem == null) return; keySerializer.serialize(keyElem, jgen, provider); } // And then value if (valueElem == null) { provider.defaultSerializeNull(jgen); } else { Class<?> cc = valueElem.getClass(); JsonSerializer<Object> ser = serializers.serializerFor(cc); if (ser == null) { if (_valueType.hasGenericTypes()) { ser = _findAndAddDynamic(serializers, provider.constructSpecializedType(_valueType, cc), provider); } else { ser = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicValueSerializers; } try { if (vts == null) { ser.serialize(valueElem, jgen, provider); } else { ser.serializeWithType(valueElem, jgen, provider, vts); } } catch (Exception e) { // [JACKSON-55] Need to add reference information String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } /** * Method called to

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> serialize fields, when the value type is statically known, * so that value serializer is passed and does not need to be fetched from * provider. */ protected void serializeUsing(Map.Entry<?, ?> value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException, JsonGenerationException { final JsonSerializer<Object> keySerializer = _keySerializer; final TypeSerializer vts = _valueTypeSerializer; final boolean skipNulls = !provider.isEnabled(SerializationFeature.WRITE_NULL_MAP_VALUES); Object valueElem = value.getValue(); Object keyElem = value.getKey(); if (keyElem == null) { provider.findNullKeySerializer(_keyType, _property).serialize(null, jgen, provider); } else { // [JACKSON-314] also may need to skip entries with null values if (skipNulls && valueElem == null) return; keySerializer.serialize(keyElem, jgen, provider); } if (valueElem == null) { provider.defaultSerializeNull(jgen); } else { try { if (vts == null) { ser.serialize(valueElem, jgen, provider); } else { ser.serializeWithType(valueElem, jgen, provider, vts); } } catch (Exception e) { // [JACKSON-55] Need to add reference information String keyDesc = ""+keyElem; wrapAndThrow(provider, e, value, keyDesc); } } } /* /********************************************************** /* Internal helper methods /********************************************************** */ protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, Class<?> type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider, _property); if (map != result.map) { _dynamicValueSerializers = result.map; } return result.serializer; } protected final JsonSerializer<Object> _findAndAddDynamic(PropertySerializerMap map, JavaType type, SerializerProvider provider) throws JsonMappingException { PropertySerializerMap.SerializerAndMapResult result = map.findAndAddSecondarySerializer(type, provider

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(len); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public void serializeContents(List<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (_elementSerializer != null) { serializeContentsUsing(value, jgen, provider, _elementSerializer); return; } if (_valueTypeSerializer != null) { serializeTypedContents(value, jgen, provider); return; } final int len = value.size(); if (len == 0) { return; } int i = 0; try { PropertySerializerMap serializers = _dynamicSerializers; for (; i < len; ++i) { Object elem = value.get(i); if (elem == null) { provider.defaultSerializeNull(jgen); } else { Class<?> cc = elem.getClass(); JsonSerializer<Object> serializer = serializers.serializerFor(cc); if (serializer == null) { // To fix [JACKSON-508] if (_elementType.hasGenericTypes()) { serializer = _findAndAddDynamic(serializers, provider.constructSpecializedType(_elementType, cc), provider); } else { serializer = _findAndAddDynamic(serializers, cc, provider); } serializers = _dynamicSerializers; } serializer.serialize(elem, jgen, provider); } } } catch (Exception e) { wrapAndThrow(provider, e, value, i); } } public void serializeContentsUsing(List<?> value, JsonGenerator jgen, SerializerProvider provider, JsonSerializer<Object> ser) throws IOException { final int len = value.size(); if (len == 0) { return; } final TypeSerializer typeSer = _valueTypeSerializer; for (int i = 0; i < len; ++i) { Object elem = value.get(i); try {

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind; import java.text.DateFormat; import java.util.*; import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility; import com.fasterxml.jackson.annotation.PropertyAccessor; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.cfg.*; import com.fasterxml.jackson.databind.deser.DeserializationProblemHandler; import com.fasterxml.jackson.databind.introspect.*; import com.fasterxml.jackson.databind.jsontype.*; import com.fasterxml.jackson.databind.node.JsonNodeFactory; import com.fasterxml.jackson.databind.type.TypeFactory; import com.fasterxml.jackson.databind.util.LinkedNode; import com.fasterxml.jackson.databind.util.RootNameLookup; /** * Object that contains baseline configuration for deserialization * process. An instance is owned by {@link ObjectMapper}, which * passes an immutable instance to be used for deserialization process. *<p> * Note that instances are considered immutable and as such no copies * should need to be created for sharing; all copying is done with * "fluent factory" methods. */ public final class DeserializationConfig extends MapperConfigBase<DeserializationFeature, DeserializationConfig> implements java.io.Serializable // since 2.1 { // since 2.5 private static final long serialVersionUID = 1; /** * Set of {@link DeserializationFeature}s enabled. */ protected final int _deserFeatures; /** * Linked list that contains all registered problem handlers. * Implementation as front-added linked list allows for sharing * of the list (tail) without copying the list. */ protected final LinkedNode<DeserializationProblemHandler> _problemHandlers; /** * Factory used for constructing {@link com.fasterxml.jackson.databind.JsonNode} instances. */ protected final JsonNodeFactory _nodeFactory; /** * States of {@link com.fasterxml.jackson.core.JsonParser.Feature}s to enable/disable. */ protected final int _parserFeatures; /** * Bitflag of {@link com.fasterxml.jackson.core.JsonParser.Feature}s to enable/disable */ protected

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> final int _parserFeaturesToChange; /* /********************************************************** /* Life-cycle, constructors /********************************************************** */ /** * Constructor used by ObjectMapper to create default configuration object instance. */ public DeserializationConfig(BaseSettings base, SubtypeResolver str, SimpleMixInResolver mixins, RootNameLookup rootNames) { super(base, str, mixins, rootNames); _deserFeatures = collectFeatureDefaults(DeserializationFeature.class); _nodeFactory = JsonNodeFactory.instance; _problemHandlers = null; _parserFeatures = 0; _parserFeaturesToChange = 0; } private DeserializationConfig(DeserializationConfig src, int mapperFeatures, int deserFeatures, int parserFeatures, int parserFeatureMask) { super(src, mapperFeatures); _deserFeatures = deserFeatures; _nodeFactory = src._nodeFactory; _problemHandlers = src._problemHandlers; _parserFeatures = parserFeatures; _parserFeaturesToChange = parserFeatureMask; } /** * Copy constructor used to create a non-shared instance with given mix-in * annotation definitions and subtype resolver. */ private DeserializationConfig(DeserializationConfig src, SubtypeResolver str) { super(src, str); _deserFeatures = src._deserFeatures; _nodeFactory = src._nodeFactory; _problemHandlers = src._problemHandlers; _parserFeatures = src._parserFeatures; _parserFeaturesToChange = src._parserFeaturesToChange; } private DeserializationConfig(DeserializationConfig src, BaseSettings base) { super(src, base); _deserFeatures = src._deserFeatures; _nodeFactory = src._nodeFactory; _problemHandlers = src._problemHandlers; _parserFeatures = src._parserFeatures; _parserFeaturesToChange = src._parserFeaturesToChange; } private DeserializationConfig(DeserializationConfig src, JsonNodeFactory f) { super(src); _deserFeatures = src._deserFeatures; _problemHandlers = src._problemHandlers; _nodeFactory = f; _parserFeatures = src._parserFeatures; _parserFeaturesToChange = src._parserFeaturesToChange; } private DeserializationConfig(DeserializationConfig src, LinkedNode

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>64)); } @Override public DeserializationConfig with(ContextAttributes attrs) { return (attrs == _attributes) ? this : new DeserializationConfig(this, attrs); } private final DeserializationConfig _withBase(BaseSettings newBase) { return (_base == newBase) ? this : new DeserializationConfig(this, newBase); } /* /********************************************************** /* Life-cycle, DeserializationFeature-based factory methods /********************************************************** */ /** * Fluent factory method that will construct and return a new configuration * object instance with specified features enabled. */ public DeserializationConfig with(DeserializationFeature feature) { int newDeserFeatures = (_deserFeatures | feature.getMask()); return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified features enabled. */ public DeserializationConfig with(DeserializationFeature first, DeserializationFeature... features) { int newDeserFeatures = _deserFeatures | first.getMask(); for (DeserializationFeature f : features) { newDeserFeatures |= f.getMask(); } return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified features enabled. */ public DeserializationConfig withFeatures(DeserializationFeature... features) { int newDeserFeatures = _deserFeatures; for (DeserializationFeature f : features) { newDeserFeatures |= f.getMask(); } return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified feature disabled. */ public DeserializationConfig without(DeserializationFeature feature) { int newDeserFeatures = _

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>deserFeatures & ~feature.getMask(); return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified features disabled. */ public DeserializationConfig without(DeserializationFeature first, DeserializationFeature... features) { int newDeserFeatures = _deserFeatures & ~first.getMask(); for (DeserializationFeature f : features) { newDeserFeatures &= ~f.getMask(); } return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified features disabled. */ public DeserializationConfig withoutFeatures(DeserializationFeature... features) { int newDeserFeatures = _deserFeatures; for (DeserializationFeature f : features) { newDeserFeatures &= ~f.getMask(); } return (newDeserFeatures == _deserFeatures) ? this : new DeserializationConfig(this, _mapperFeatures, newDeserFeatures, _parserFeatures, _parserFeaturesToChange); } /* /********************************************************** /* Life-cycle, JsonParser.Feature-based factory methods /********************************************************** */ /** * Fluent factory method that will construct and return a new configuration * object instance with specified features enabled. * * @since 2.5 */ public DeserializationConfig with(JsonParser.Feature feature) { int newSet = _parserFeatures | feature.getMask(); int newMask = _parserFeaturesToChange | feature.getMask(); return ((_parserFeatures == newSet) && (_parserFeaturesToChange == newMask)) ? this : new DeserializationConfig(this, _mapperFeatures, _deserFeatures, newSet, newMask); } /** * Fluent factory method that will construct and return a new configuration * object instance with specified features enabled. * * @since 2.5 */ public Deserialization

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> (try to) * resolve non-fatal deserialization problems. */ public DeserializationConfig withHandler(DeserializationProblemHandler h) { // Sanity check: let's prevent adding same handler multiple times if (LinkedNode.contains(_problemHandlers, h)) { return this; } return new DeserializationConfig(this, new LinkedNode<DeserializationProblemHandler>(h, _problemHandlers)); } /** * Method for removing all configured problem handlers; usually done to replace * existing handler(s) with different one(s) */ public DeserializationConfig withNoProblemHandlers() { if (_problemHandlers == null) { return this; } return new DeserializationConfig(this, (LinkedNode<DeserializationProblemHandler>) null); } /* /********************************************************** /* JsonParser initialization /********************************************************** */ /** * Method called by {@link ObjectMapper} and {@link ObjectReader} * to modify those {@link com.fasterxml.jackson.core.JsonParser.Feature} settings * that have been configured via this config instance. * * @since 2.5 */ public void initialize(JsonParser p) { if (_parserFeaturesToChange != 0) { int orig = p.getFeatureMask(); int newFlags = (orig & ~_parserFeaturesToChange) | _parserFeatures; if (orig != newFlags) { p.setFeatureMask(newFlags); } } } /* /********************************************************** /* MapperConfig implementation /********************************************************** */ /** * Method for getting {@link AnnotationIntrospector} configured * to introspect annotation values used for configuration. */ @Override public AnnotationIntrospector getAnnotationIntrospector() { /* 29-Jul-2009, tatu: it's now possible to disable use of * annotations; can be done using "no-op" introspector */ if (isEnabled(MapperFeature.USE_ANNOTATIONS)) { return super.getAnnotationIntrospector(); } return NopAnnotationIntrospector.instance; } @Override public boolean useRootWrapping() { if (_rootName != null) { // empty String disables wrapping; non-empty enables return !_rootName.isEmpty();

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> } return isEnabled(DeserializationFeature.UNWRAP_ROOT_VALUE); } /** * Accessor for getting bean description that only contains class * annotations: useful if no getter/setter/creator information is needed. */ @Override public BeanDescription introspectClassAnnotations(JavaType type) { return getClassIntrospector().forClassAnnotations(this, type, this); } /** * Accessor for getting bean description that only contains immediate class * annotations: ones from the class, and its direct mix-in, if any, but * not from super types. */ @Override public BeanDescription introspectDirectClassAnnotations(JavaType type) { return getClassIntrospector().forDirectClassAnnotations(this, type, this); } @Override public VisibilityChecker<?> getDefaultVisibilityChecker() { VisibilityChecker<?> vchecker = super.getDefaultVisibilityChecker(); if (!isEnabled(MapperFeature.AUTO_DETECT_SETTERS)) { vchecker = vchecker.withSetterVisibility(Visibility.NONE); } if (!isEnabled(MapperFeature.AUTO_DETECT_CREATORS)) { vchecker = vchecker.withCreatorVisibility(Visibility.NONE); } if (!isEnabled(MapperFeature.AUTO_DETECT_FIELDS)) { vchecker = vchecker.withFieldVisibility(Visibility.NONE); } return vchecker; } public final boolean isEnabled(DeserializationFeature f) { return (_deserFeatures & f.getMask()) != 0; } public final boolean isEnabled(JsonParser.Feature f, JsonFactory factory) { int mask = f.getMask(); if ((_parserFeaturesToChange & mask) != 0) { return (_parserFeatures & f.getMask()) != 0; } return factory.isEnabled(f); } /** * Bulk access method for checking that all features specified by * mask are enabled. * * @since 2.3 */ public final boolean hasDeserializationFeatures(int featureMask) { return (_deserFeatures & featureMask) == featureMask; } /** * Bulk access method for checking that at least one of features specified by * mask is enabled. * * @since 2.6 */ public final boolean hasSomeOfFeatures(int featureMask

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> b = getAnnotationIntrospector().findTypeResolver(this, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = getDefaultTyper(baseType); if (b == null) { return null; } } else { subtypes = getSubtypeResolver().collectAndResolveSubtypesByTypeId(this, ac); } /* 04-May-2014, tatu: When called from DeserializerFactory, additional code like * this is invoked. But here we do not actually have access to mappings, so not * quite sure what to do, if anything. May need to revisit if the underlying * problem re-surfaces... */ /* if ((b.getDefaultImpl() == null) && baseType.isAbstract()) { JavaType defaultType = mapAbstractType(config, baseType); if (defaultType != null && defaultType.getRawClass() != baseType.getRawClass()) { b = b.defaultImpl(defaultType.getRawClass()); } } */ return b.buildTypeDeserializer(this, baseType, subtypes); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> /** * Method that will modify caught exception (passed in as argument) * as necessary to include reference information, and to ensure it * is a subtype of {@link IOException}, or an unchecked exception. *<p> * Rules for wrapping and unwrapping are bit complicated; essentially: *<ul> * <li>Errors are to be passed as is (if uncovered via unwrapping) * <li>"Plain" IOExceptions (ones that are not of type * {@link JsonMappingException} are to be passed as is *</ul> */ public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, String fieldName) throws IOException { /* 05-Mar-2009, tatu: But one nasty edge is when we get * StackOverflow: usually due to infinite loop. But that * usually gets hidden within an InvocationTargetException... */ while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors and "plain" IOExceptions to be passed as is if (t instanceof Error) { throw (Error) t; } // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled(SerializationFeature.WRAP_EXCEPTIONS); if (t instanceof IOException) { if (!wrap || !(t instanceof JsonMappingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } // [JACKSON-55] Need to add reference information throw JsonMappingException.wrapWithPath(t, bean, fieldName); } public void wrapAndThrow(SerializerProvider provider, Throwable t, Object bean, int index) throws IOException { while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors are to be passed as is if (t instanceof Error) { throw (Error) t; } // Ditto for IOExceptions... except for mapping exceptions! boolean wrap = (provider == null) || provider.isEnabled

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> (UnresolvedForwardReference reference) { if (referringAccumulator == null) { throw JsonMappingException .from(p, "Unresolved forward reference but no identity info", reference); } Referring ref = referringAccumulator.handleUnresolvedReference(reference); reference.getRoid().appendReferring(ref); } catch (Exception e) { boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); if (!wrap && e instanceof RuntimeException) { throw (RuntimeException)e; } throw JsonMappingException.wrapWithPath(e, result, result.size()); } } return result; } @Override public Object deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException { // In future could check current token... for now this should be enough: return typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /** * Helper method called when current token is no START_ARRAY. Will either * throw an exception, or try to handle value as if member of implicit * array, depending on configuration. */ protected final Collection<Object> handleNonArray(JsonParser p, DeserializationContext ctxt, Collection<Object> result) throws IOException { // [JACKSON-526]: implicit arrays from single values? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { throw ctxt.mappingException(_collectionType.getRawClass()); } JsonDeserializer<Object> valueDes = _valueDeserializer; final TypeDeserializer typeDeser = _valueTypeDeserializer; JsonToken t = p.getCurrentToken(); Object value; try { if (t == JsonToken.VALUE_NULL) { value = valueDes.getNullValue(ctxt); } else if (typeDeser == null) { value = valueDes.deserialize(p, ctxt); } else { value = valueDes.deserializeWithType(p, ctxt, typeDeser); } } catch (Exception e) { // note: pass Object.class, not Object[].class, as we need element type for error info throw JsonMappingException.wrapWithPath(e, Object.class, result.size()); } result.add(value);

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> xf.transform(prop.getName()); prop = prop.withSimpleName(newName); JsonDeserializer<?> deser = prop.getValueDeserializer(); if (deser != null) { @SuppressWarnings("unchecked") JsonDeserializer<Object> newDeser = (JsonDeserializer<Object>) deser.unwrappingDeserializer(xf); if (newDeser != deser) { prop = prop.withValueDeserializer(newDeser); } } return prop; } protected void wrapAndThrow(Throwable t, Object bean, String fieldName, DeserializationContext ctxt) throws IOException { // inlined 'throwOrReturnThrowable' while (t instanceof InvocationTargetException && t.getCause() != null) { t = t.getCause(); } // Errors to be passed as is if (t instanceof Error) { throw (Error) t; } // StackOverflowErrors are tricky ones; need to be careful... boolean wrap = (ctxt == null) || ctxt.isEnabled(DeserializationFeature.WRAP_EXCEPTIONS); // Ditto for IOExceptions; except we may want to wrap JSON exceptions if (t instanceof IOException) { if (!wrap || !(t instanceof JsonProcessingException)) { throw (IOException) t; } } else if (!wrap) { // [JACKSON-407] -- allow disabling wrapping for unchecked exceptions if (t instanceof RuntimeException) { throw (RuntimeException) t; } } throw JsonMappingException.wrapWithPath(t, bean, fieldName); } private int _findFromOrdered(SettableBeanProperty prop) { for (int i = 0, end = _propsInOrder.length; i < end; ++i) { if (_propsInOrder[i] == prop) { return i; } } throw new IllegalStateException("Illegal state: property '"+prop.getName()+"' missing from _propsInOrder"); } // Offlined version for convenience if we want to change hashing scheme private final int _hashCode(String key) { // This method produces better hash, fewer collisions... yet for some // reason produces slightly worse performance. Very strange. // 05-Aug-2015, tatu: ... still true? /* int h = key.hashCode(); return (h +

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> BeanDescription beanDesc, VisibilityChecker<?> vchecker, AnnotationIntrospector intr, CreatorCollector creators, AnnotatedMethod factory, boolean isCreator) throws JsonMappingException { Class<?> type = factory.getRawParameterType(0); if (type == String.class || type == CharSequence.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addStringCreator(factory, isCreator); } return true; } if (type == int.class || type == Integer.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addIntCreator(factory, isCreator); } return true; } if (type == long.class || type == Long.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addLongCreator(factory, isCreator); } return true; } if (type == double.class || type == Double.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addDoubleCreator(factory, isCreator); } return true; } if (type == boolean.class || type == Boolean.class) { if (isCreator || vchecker.isCreatorVisible(factory)) { creators.addBooleanCreator(factory, isCreator); } return true; } if (isCreator) { creators.addDelegatingCreator(factory, isCreator, null); return true; } return false; } /** * Method that will construct a property object that represents * a logical property passed via Creator (constructor or static * factory method) */ protected SettableBeanProperty constructCreatorProperty(DeserializationContext ctxt, BeanDescription beanDesc, PropertyName name, int index, AnnotatedParameter param, Object injectableValueId) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); final AnnotationIntrospector intr = ctxt.getAnnotationIntrospector(); PropertyMetadata metadata; { if (intr == null) { metadata = PropertyMetadata.STD_REQUIRED_OR_OPTIONAL; } else { Boolean b = intr.hasRequiredMarker(param); boolean req = (b != null

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> && b.booleanValue()); String desc = intr.findPropertyDescription(param); Integer idx = intr.findPropertyIndex(param); String def = intr.findPropertyDefaultValue(param); metadata = PropertyMetadata.construct(req, desc, idx, def); } } JavaType t0 = config.getTypeFactory().constructType(param.getParameterType(), beanDesc.bindingsForBeanType()); BeanProperty.Std property = new BeanProperty.Std(name, t0, intr.findWrapperName(param), beanDesc.getClassAnnotations(), param, metadata); JavaType type = resolveType(ctxt, beanDesc, t0, param); if (type != t0) { property = property.withType(type); } // Is there an annotation that specifies exact deserializer? JsonDeserializer<?> deser = findDeserializerFromAnnotation(ctxt, param); // If yes, we are mostly done: type = modifyTypeByAnnotation(ctxt, param, type); // Type deserializer: either comes from property (and already resolved) TypeDeserializer typeDeser = (TypeDeserializer) type.getTypeHandler(); // or if not, based on type being referenced: if (typeDeser == null) { typeDeser = findTypeDeserializer(config, type); } // Note: contextualization of typeDeser _should_ occur in constructor of CreatorProperty // so it is not called directly here SettableBeanProperty prop = new CreatorProperty(name, type, property.getWrapperName(), typeDeser, beanDesc.getClassAnnotations(), param, index, injectableValueId, metadata); if (deser != null) { // As per [Issue#462] need to ensure we contextualize deserializer before passing it on deser = ctxt.handlePrimaryContextualization(deser, prop, type); prop = prop.withValueDeserializer(deser); } return prop; } protected PropertyName _findParamName(AnnotatedParameter param, AnnotationIntrospector intr) { if (param != null && intr != null) { PropertyName name = intr.findNameForDeserialization(param); if (name != null) { return name; } // 14-Apr-2014, tatu: Need to also consider

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>deser == null) { deser = new EnumDeserializer(constructEnumResolver(enumClass, config, beanDesc.findJsonValueMethod())); } } // and then new with 2.2: ability to post-process it too (Issue#120) if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyEnumDeserializer(config, type, beanDesc, deser); } } return deser; } /* /********************************************************** /* JsonDeserializerFactory impl: Tree deserializers /********************************************************** */ @Override public JsonDeserializer<?> createTreeDeserializer(DeserializationConfig config, JavaType nodeType, BeanDescription beanDesc) throws JsonMappingException { @SuppressWarnings("unchecked") Class<? extends JsonNode> nodeClass = (Class<? extends JsonNode>) nodeType.getRawClass(); // 23-Nov-2010, tatu: Custom deserializer? JsonDeserializer<?> custom = _findCustomTreeNodeDeserializer(nodeClass, config, beanDesc); if (custom != null) { return custom; } return JsonNodeDeserializer.getDeserializer(nodeClass); } /* /********************************************************** /* JsonDeserializerFactory impl (partial): type deserializers /********************************************************** */ @Override public TypeDeserializer findTypeDeserializer(DeserializationConfig config, JavaType baseType) throws JsonMappingException { BeanDescription bean = config.introspectClassAnnotations(baseType.getRawClass()); AnnotatedClass ac = bean.getClassInfo(); AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findTypeResolver(config, ac, baseType); /* Ok: if there is no explicit type info handler, we may want to * use a default. If so, config object knows what to use. */ Collection<NamedType> subtypes = null; if (b == null) { b = config.getDefaultTyper(baseType); if (b == null) { return null; } } else { subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId(config, ac); } // [JACKSON-505]: May need to figure out default implementation, if none

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> found yet // (note: check for abstract type is not 100% mandatory, more of an optimization) if ((b.getDefaultImpl() == null) && baseType.isAbstract()) { JavaType defaultType = mapAbstractType(config, baseType); if (defaultType != null && defaultType.getRawClass() != baseType.getRawClass()) { b = b.defaultImpl(defaultType.getRawClass()); } } return b.buildTypeDeserializer(config, baseType, subtypes); } /** * Overridable method called after checking all other types. * * @since 2.2 */ protected JsonDeserializer<?> findOptionalStdDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { return OptionalHandlerFactory.instance.findDeserializer(type, ctxt.getConfig(), beanDesc); } /* /********************************************************** /* JsonDeserializerFactory impl (partial): key deserializers /********************************************************** */ @Override public KeyDeserializer createKeyDeserializer(DeserializationContext ctxt, JavaType type) throws JsonMappingException { final DeserializationConfig config = ctxt.getConfig(); KeyDeserializer deser = null; if (_factoryConfig.hasKeyDeserializers()) { BeanDescription beanDesc = config.introspectClassAnnotations(type.getRawClass()); for (KeyDeserializers d : _factoryConfig.keyDeserializers()) { deser = d.findKeyDeserializer(type, config, beanDesc); if (deser != null) { break; } } } // the only non-standard thing is this: if (deser == null) { if (type.isEnumType()) { return _createEnumKeyDeserializer(ctxt, type); } deser = StdKeyDeserializers.findStringBasedKeyDeserializer(config, type); } // and then new with 2.2: ability to post-process it too (Issue#120) if (deser != null) { if (_factoryConfig.hasDeserializerModifiers()) { for (BeanDeserializerModifier mod : _factoryConfig.deserializerModifiers()) { deser = mod.modifyKeyDeserializer(config, type, deser); } } } return deser; } private KeyDeserializer _createEnumKey

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>+") decorated with @JsonCreator (for Enum type " +enumClass.getName()+")"); } } // [JACKSON-749] Also, need to consider @JsonValue, if one found return StdKeyDeserializers.constructEnumKeyDeserializer(enumRes); } /* /********************************************************** /* Extended API /********************************************************** */ /** * Method called to create a type information deserializer for values of * given non-container property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for non-container bean properties, * and not for values in container types or root values (or container properties) * * @param baseType Declared base type of the value to deserializer (actual * deserializer type will be this type or its subtype) * * @return Type deserializer to use for given base type, if one is needed; null if not. */ public TypeDeserializer findPropertyTypeDeserializer(DeserializationConfig config, JavaType baseType, AnnotatedMember annotated) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyTypeResolver(config, annotated, baseType); // Defaulting: if no annotations on member, check value class if (b == null) { return findTypeDeserializer(config, baseType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId( config, annotated, baseType); return b.buildTypeDeserializer(config, baseType, subtypes); } /** * Method called to find and create a type information deserializer for values of * given container (list, array, map) property, if one is needed. * If not needed (no polymorphic handling configured for property), should return null. *<p> * Note that this method is only called for container bean properties, * and not for values in container types or root values (or non-container properties) * * @param containerType Type of property; must be a container type * @param propertyEntity Field or method that contains container

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> property */ public TypeDeserializer findPropertyContentTypeDeserializer(DeserializationConfig config, JavaType containerType, AnnotatedMember propertyEntity) throws JsonMappingException { AnnotationIntrospector ai = config.getAnnotationIntrospector(); TypeResolverBuilder<?> b = ai.findPropertyContentTypeResolver(config, propertyEntity, containerType); JavaType contentType = containerType.getContentType(); // Defaulting: if no annotations on member, check class if (b == null) { return findTypeDeserializer(config, contentType); } // but if annotations found, may need to resolve subtypes: Collection<NamedType> subtypes = config.getSubtypeResolver().collectAndResolveSubtypesByTypeId( config, propertyEntity, contentType); return b.buildTypeDeserializer(config, contentType, subtypes); } /** * Helper method called to find one of default serializers for "well-known" * platform types: JDK-provided types, and small number of public Jackson * API types. * * @since 2.2 */ public JsonDeserializer<?> findDefaultDeserializer(DeserializationContext ctxt, JavaType type, BeanDescription beanDesc) throws JsonMappingException { Class<?> rawType = type.getRawClass(); // Object ("untyped"), String equivalents: if (rawType == CLASS_OBJECT) { // 11-Feb-2015, tatu: As per [databind#700] need to be careful wrt non-default Map, List. DeserializationConfig config = ctxt.getConfig(); JavaType lt, mt; if (_factoryConfig.hasAbstractTypeResolvers()) { lt = _findRemappedType(config, List.class); mt = _findRemappedType(config, Map.class); } else { lt = mt = null; } return new UntypedObjectDeserializer(lt, mt); } if (rawType == CLASS_STRING || rawType == CLASS_CHAR_BUFFER) { return StringDeserializer.instance; } if (type.isReferenceType()) { JavaType referencedType = type.getReferencedType(); if (AtomicReference.class.isAssignableFrom(rawType)) { TypeDeserializer vts = findTypeDeserializer(ctxt.getConfig(), referencedType); BeanDescription refdDesc = ctxt.getConfig

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>), not classes */ if (member instanceof AnnotatedMember) { TypeDeserializer contentTypeDeser = findPropertyContentTypeDeserializer( ctxt.getConfig(), type, (AnnotatedMember) member); if (contentTypeDeser != null) { type = type.withContentTypeHandler(contentTypeDeser); } } } TypeDeserializer valueTypeDeser; if (member instanceof AnnotatedMember) { // JAXB allows per-property annotations valueTypeDeser = findPropertyTypeDeserializer(ctxt.getConfig(), type, (AnnotatedMember) member); } else { // classes just have Jackson annotations // probably only occurs if 'property' is null anyway valueTypeDeser = findTypeDeserializer(ctxt.getConfig(), type); } if (valueTypeDeser != null) { type = type.withTypeHandler(valueTypeDeser); } return type; } protected EnumResolver constructEnumResolver(Class<?> enumClass, DeserializationConfig config, AnnotatedMethod jsonValueMethod) { if (jsonValueMethod != null) { Method accessor = jsonValueMethod.getAnnotated(); if (config.canOverrideAccessModifiers()) { ClassUtil.checkAndFixAccess(accessor); } return EnumResolver.constructUnsafeUsingMethod(enumClass, accessor); } // [JACKSON-212]: may need to use Enum.toString() if (config.isEnabled(DeserializationFeature.READ_ENUMS_USING_TO_STRING)) { return EnumResolver.constructUnsafeUsingToString(enumClass); } return EnumResolver.constructUnsafe(enumClass, config.getAnnotationIntrospector()); } protected AnnotatedMethod _findJsonValueFor(DeserializationConfig config, JavaType enumType) { if (enumType == null) { return null; } BeanDescription beanDesc = config.introspect(enumType); return beanDesc.findJsonValueMethod(); } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> deserializers won't Object value; if (t == JsonToken.VALUE_NULL) { value = _elementDeserializer.getNullValue(ctxt); } else if (typeDeser == null) { value = _elementDeserializer.deserialize(jp, ctxt); } else { value = _elementDeserializer.deserializeWithType(jp, ctxt, typeDeser); } if (ix >= chunk.length) { chunk = buffer.appendCompletedChunk(chunk); ix = 0; } chunk[ix++] = value; } } catch (Exception e) { throw JsonMappingException.wrapWithPath(e, chunk, buffer.bufferedSize() + ix); } Object[] result; if (_untyped) { result = buffer.completeAndClearBuffer(chunk, ix); } else { result = buffer.completeAndClearBuffer(chunk, ix, _elementClass); } ctxt.returnObjectBuffer(buffer); return result; } @Override public Object[] deserializeWithType(JsonParser jp, DeserializationContext ctxt, TypeDeserializer typeDeserializer) throws IOException, JsonProcessingException { /* Should there be separate handling for base64 stuff? * for now this should be enough: */ return (Object[]) typeDeserializer.deserializeTypedFromArray(jp, ctxt); } /* /********************************************************** /* Internal methods /********************************************************** */ protected Byte[] deserializeFromBase64(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // First same as what PrimitiveArrayDeserializers.ByteDeser does: byte[] b = jp.getBinaryValue(ctxt.getBase64Variant()); // But then need to convert to wrappers Byte[] result = new Byte[b.length]; for (int i = 0, len = b.length; i < len; ++i) { result[i] = Byte.valueOf(b[i]); } return result; } private final Object[] handleNonArray(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException { // [JACKSON-620] Empty String can become null... if ((jp.getCurrentToken() == JsonToken.VALUE_STRING) && ctxt.isEnabled(DeserializationFeature.ACCEPT

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>_EMPTY_STRING_AS_NULL_OBJECT)) { String str = jp.getText(); if (str.length() == 0) { return null; } } // Can we do implicit coercion to a single-element array still? if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY)) { /* 04-Oct-2009, tatu: One exception; byte arrays are generally * serialized as base64, so that should be handled */ if (jp.getCurrentToken() == JsonToken.VALUE_STRING && _elementClass == Byte.class) { return deserializeFromBase64(jp, ctxt); } throw ctxt.mappingException(_arrayType.getRawClass()); } JsonToken t = jp.getCurrentToken(); Object value; if (t == JsonToken.VALUE_NULL) { value = _elementDeserializer.getNullValue(ctxt); } else if (_elementTypeDeserializer == null) { value = _elementDeserializer.deserialize(jp, ctxt); } else { value = _elementDeserializer.deserializeWithType(jp, ctxt, _elementTypeDeserializer); } // Ok: bit tricky, since we may want T[], not just Object[] Object[] result; if (_untyped) { result = new Object[1]; } else { result = (Object[]) Array.newInstance(_elementClass, 1); } result[0] = value; return result; } }

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>Override public CollectionSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new CollectionSerializer(this, property, vts, elementSerializer, unwrapSingle); } /* /********************************************************** /* Accessors /********************************************************** */ @Override public boolean isEmpty(SerializerProvider prov, Collection<?> value) { return (value == null) || value.isEmpty(); } @Override public boolean hasSingleElement(Collection<?> value) { Iterator<?> it = value.iterator(); if (!it.hasNext()) { return false; } it.next(); return !it.hasNext(); } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public final void serialize(Collection<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, jgen, provider); return; } } jgen.writeStartArray(len); serializeContents(value, jgen, provider); jgen.writeEndArray(); } @Override public void serializeContents(Collection<?> value, JsonGenerator jgen, SerializerProvider provider) throws IOException { if (_elementSerializer != null) { serializeContentsUsing(value, jgen, provider, _elementSerializer); return; } Iterator<?> it = value.iterator(); if (!it.hasNext()) { return; } PropertySerializerMap serializers = _dynamicSerializers; final TypeSerializer typeSer = _valueTypeSerializer; int i = 0; try { do { Object elem = it.next(); if (elem == null) { provider.defaultSerializeNull(jgen); } else { Class<?> cc = elem.getClass(); JsonSerializer<Object> serializer = serializers.serializerFor(cc); if (serializer == null) { // To fix [JACKSON-508] if (_elementType.hasGenericTypes()) { serializer = _findAndAddDynamic(serializers,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>package com.fasterxml.jackson.databind.ser.std; import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @SuppressWarnings("serial") public class EnumSetSerializer extends AsArraySerializerBase<EnumSet<? extends Enum<?>>> { /** * @since 2.6 */ public EnumSetSerializer(JavaType elemType) { super(EnumSet.class, elemType, true, null, null); } /** * @deprecated since 2.6 */ @Deprecated // since 2.6 public EnumSetSerializer(JavaType elemType, BeanProperty property) { this(elemType); } public EnumSetSerializer(EnumSetSerializer src, BeanProperty property, TypeSerializer vts, JsonSerializer<?> valueSerializer, Boolean unwrapSingle) { super(src, property, vts, valueSerializer, unwrapSingle); } @Override public EnumSetSerializer _withValueTypeSerializer(TypeSerializer vts) { // no typing for enums (always "hard" type) return this; } @Override public EnumSetSerializer withResolved(BeanProperty property, TypeSerializer vts, JsonSerializer<?> elementSerializer, Boolean unwrapSingle) { return new EnumSetSerializer(this, property, vts, elementSerializer, unwrapSingle); } @Override public boolean isEmpty(SerializerProvider prov, EnumSet<? extends Enum<?>> value) { return (value == null) || value.isEmpty(); } @Override public boolean hasSingleElement(EnumSet<? extends Enum<?>> value) { return value.size() == 1; } @Override public final void serialize(EnumSet<? extends Enum<?>> value, JsonGenerator gen, SerializerProvider provider) throws IOException { final int len = value.size(); if (len == 1) { if (((_unwrapSingle == null) && provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) || (_unwrapSingle == Boolean.TRUE)) { serializeContents(value, gen, provider); return; } } gen.writeStartArray(len); serializeContents

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> * If set, will not throw an exception for unknown properties. */ protected boolean _ignoreAllUnknown; /** * When creating Builder-based deserializers, this indicates * method to call on builder to finalize value. */ protected AnnotatedMethod _buildMethod; /** * In addition, Builder may have additional configuration */ protected JsonPOJOBuilder.Value _builderConfig; /* /********************************************************** /* Life-cycle: construction /********************************************************** */ public BeanDeserializerBuilder(BeanDescription beanDesc, DeserializationConfig config) { _beanDesc = beanDesc; _defaultViewInclusion = config.isEnabled(MapperFeature.DEFAULT_VIEW_INCLUSION); _caseInsensitivePropertyComparison = config.isEnabled(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES); } /** * Copy constructor for sub-classes to use, when constructing * custom builder instances */ protected BeanDeserializerBuilder(BeanDeserializerBuilder src) { _beanDesc = src._beanDesc; _defaultViewInclusion = src._defaultViewInclusion; _caseInsensitivePropertyComparison = src._caseInsensitivePropertyComparison; // let's make copy of properties _properties.putAll(src._properties); _injectables = _copy(src._injectables); _backRefProperties = _copy(src._backRefProperties); // Hmmh. Should we create defensive copies here? For now, not yet _ignorableProps = src._ignorableProps; _valueInstantiator = src._valueInstantiator; _objectIdReader = src._objectIdReader; _anySetter = src._anySetter; _ignoreAllUnknown = src._ignoreAllUnknown; _buildMethod = src._buildMethod; _builderConfig = src._builderConfig; } private static HashMap<String, SettableBeanProperty> _copy(HashMap<String, SettableBeanProperty> src) { return (src == null) ? null : new HashMap<String, SettableBeanProperty>(src); } private static <T> List<T> _copy(List<T> src) { return (src == null) ? null : new ArrayList<T>(src); } /* /********************************************************** /* Life-cycle: state modification (adders, set

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> multiple values means that we may or may not want to advance the stream, * but need to do other initialization. *<p> * Base implementation only sets configured {@link FormatSchema}, if any, on parser. * * @since 2.5 */ protected void _initForMultiRead(JsonParser p) throws IOException { if (_schema != null) { p.setSchema(_schema); } _config.initialize(p); // since 2.5 } /* /********************************************************** /* Life-cycle, fluent factory methods for DeserializationFeatures /********************************************************** */ /** * Method for constructing a new reader instance that is configured * with specified feature enabled. */ public ObjectReader with(DeserializationFeature feature) { return _with(_config.with(feature)); } /** * Method for constructing a new reader instance that is configured * with specified features enabled. */ public ObjectReader with(DeserializationFeature first, DeserializationFeature... other) { return _with(_config.with(first, other)); } /** * Method for constructing a new reader instance that is configured * with specified features enabled. */ public ObjectReader withFeatures(DeserializationFeature... features) { return _with(_config.withFeatures(features)); } /** * Method for constructing a new reader instance that is configured * with specified feature disabled. */ public ObjectReader without(DeserializationFeature feature) { return _with(_config.without(feature)); } /** * Method for constructing a new reader instance that is configured * with specified features disabled. */ public ObjectReader without(DeserializationFeature first, DeserializationFeature... other) { return _with(_config.without(first, other)); } /** * Method for constructing a new reader instance that is configured * with specified features disabled. */ public ObjectReader withoutFeatures(DeserializationFeature... features) { return _with(_config.withoutFeatures(features)); } /* /********************************************************** /* Life-cycle, fluent factory methods for JsonParser.Features /********************************************************** */ /** * Method for constructing a new reader instance that is configured * with specified feature enabled. */ public ObjectReader with(JsonParser.Feature feature) { return _with(_config

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> * @since 2.3 */ public ObjectReader withAttributes(Map<Object,Object> attrs) { return _with(_config.withAttributes(attrs)); } /** * @since 2.3 */ public ObjectReader withAttribute(Object key, Object value) { return _with( _config.withAttribute(key, value)); } /** * @since 2.3 */ public ObjectReader withoutAttribute(Object key) { return _with(_config.withoutAttribute(key)); } /* /********************************************************** /* Overridable factory methods may override /********************************************************** */ protected ObjectReader _with(DeserializationConfig newConfig) { if (newConfig == _config) { return this; } ObjectReader r = _new(this, newConfig); if (_dataFormatReaders != null) { r = r.withFormatDetection(_dataFormatReaders.with(newConfig)); } return r; } /* /********************************************************** /* Simple accessors /********************************************************** */ public boolean isEnabled(DeserializationFeature f) { return _config.isEnabled(f); } public boolean isEnabled(MapperFeature f) { return _config.isEnabled(f); } public boolean isEnabled(JsonParser.Feature f) { return _parserFactory.isEnabled(f); } /** * @since 2.2 */ public DeserializationConfig getConfig() { return _config; } /** * @since 2.1 */ @Override public JsonFactory getFactory() { return _parserFactory; } public TypeFactory getTypeFactory() { return _config.getTypeFactory(); } /** * @since 2.3 */ public ContextAttributes getAttributes() { return _config.getAttributes(); } /** * @since 2.6 */ public InjectableValues getInjectableValues() { return _injectableValues; } /* /********************************************************** /* Deserialization methods; basic ones to support ObjectCodec first /* (ones that take JsonParser) /********************************************************** */ /** * Method that binds content read using given parser, using * configuration of this reader, including expected result type. * Value return is either newly

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, locating deserializers etc /********************************************************** */ /** * Method called to locate deserializer for the passed root-level value. */ protected JsonDeserializer<Object> _findRootDeserializer(DeserializationContext ctxt) throws JsonMappingException { if (_rootDeserializer != null) { return _rootDeserializer; } // Sanity check: must have actual type... JavaType t = _valueType; if (t == null) { throw new JsonMappingException("No value type configured for ObjectReader"); } // First: have we already seen it? JsonDeserializer<Object> deser = _rootDeserializers.get(t); if (deser != null) { return deser; } // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(t); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+t); } _rootDeserializers.put(t, deser); return deser; } /** * @since 2.6 */ protected JsonDeserializer<Object> _findTreeDeserializer(DeserializationContext ctxt) throws JsonMappingException { JsonDeserializer<Object> deser = _rootDeserializers.get(JSON_NODE_TYPE); if (deser == null) { // Nope: need to ask provider to resolve it deser = ctxt.findRootValueDeserializer(JSON_NODE_TYPE); if (deser == null) { // can this happen? throw new JsonMappingException("Can not find a deserializer for type "+JSON_NODE_TYPE); } _rootDeserializers.put(JSON_NODE_TYPE, deser); } return deser; } /** * Method called to locate deserializer ahead of time, if permitted * by configuration. Method also is NOT to throw an exception if * access fails. */ protected JsonDeserializer<Object> _prefetchRootDeserializer(JavaType valueType) { if (valueType == null || !_config.isEnabled(DeserializationFeature.EAGER_DESERIALIZER_FETCH)) { return null; } // already cached? JsonDeserializer<Object> deser = _rootDeserializers.get(valueType); if (deser == null) { try

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> if (provider.isEnabled(MapperFeature.USE_STATIC_TYPING) || Modifier.isFinal(_accessorMethod.getReturnType().getModifiers())) { JavaType t = provider.constructType(_accessorMethod.getGenericReturnType()); // false -> no need to cache /* 10-Mar-2010, tatu: Ideally we would actually separate out type * serializer from value serializer; but, alas, there's no access * to serializer factory at this point... */ // 05-Sep-2013, tatu: I _think_ this can be considered a primary property... ser = provider.findPrimaryPropertySerializer(t, property); /* 09-Dec-2010, tatu: Turns out we must add special handling for * cases where "native" (aka "natural") type is being serialized, * using standard serializer */ boolean forceTypeInformation = isNaturalTypeWithStdHandling(t.getRawClass(), ser); return withResolved(property, ser, forceTypeInformation); } } else { // 05-Sep-2013, tatu: I _think_ this can be considered a primary property... ser = provider.handlePrimaryContextualization(ser, property); return withResolved(property, ser, _forceTypeInformation); } return this; } /* /********************************************************** /* Actual serialization /********************************************************** */ @Override public void serialize(Object bean, JsonGenerator jgen, SerializerProvider prov) throws IOException { try { Object value = _accessorMethod.invoke(bean); if (value == null) { prov.defaultSerializeNull(jgen); return; } JsonSerializer<Object> ser = _valueSerializer; if (ser == null) { Class<?> c = value.getClass(); /* 10-Mar-2010, tatu: Ideally we would actually separate out type * serializer from value serializer; but, alas, there's no access * to serializer factory at this point... */ // let's cache it, may be needed soon again ser = prov.findTypedValueSerializer(c, true, _property); } ser.serialize(value, jgen,

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>) { _base = src._base; _mapperFeatures = mapperFeatures; } protected MapperConfig(MapperConfig<T> src, BaseSettings base) { _base = base; _mapperFeatures = src._mapperFeatures; } protected MapperConfig(MapperConfig<T> src) { _base = src._base; _mapperFeatures = src._mapperFeatures; } /** * Method that calculates bit set (flags) of all features that * are enabled by default. */ public static <F extends Enum<F> & ConfigFeature> int collectFeatureDefaults(Class<F> enumClass) { int flags = 0; for (F value : enumClass.getEnumConstants()) { if (value.enabledByDefault()) { flags |= value.getMask(); } } return flags; } /* /********************************************************** /* Life-cycle: factory methods /********************************************************** */ /** * Method for constructing and returning a new instance with specified * mapper features enabled. */ public abstract T with(MapperFeature... features); /** * Method for constructing and returning a new instance with specified * mapper features disabled. */ public abstract T without(MapperFeature... features); /** * @since 2.3 */ public abstract T with(MapperFeature feature, boolean state); /* /********************************************************** /* Configuration: simple features /********************************************************** */ /** * Accessor for simple mapper features (which are shared for * serialization, deserialization) */ public final boolean isEnabled(MapperFeature f) { return (_mapperFeatures & f.getMask()) != 0; } /** * "Bulk" access method for checking that all features specified by * mask are enabled. * * @since 2.3 */ public final boolean hasMapperFeatures(int featureMask) { return (_mapperFeatures & featureMask) == featureMask; } /** * Method for determining whether annotation processing is enabled or not * (default settings are typically that it is enabled; must explicitly disable). * * @return True if annotation processing is enabled; false if not */ public final boolean isAnnotationProcessingEnabled() { return isEnabled(MapperFeature.USE_ANNOTATIONS);

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS> } /** * Accessor for determining whether it is ok to try to force override of access * modifiers to be able to get or set values of non-public Methods, Fields; * to invoke non-public Constructors, Methods; or to instantiate non-public * Classes. By default this is enabled, but on some platforms it needs to be * prevented since if this would violate security constraints and cause failures. * * @return True if access modifier overriding is allowed (and may be done for * any Field, Method, Constructor or Class); false to prevent any attempts * to override. */ public final boolean canOverrideAccessModifiers() { return isEnabled(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS); } /** * Accessor for checking whether default settings for property handling * indicate that properties should be alphabetically ordered or not. */ public final boolean shouldSortPropertiesAlphabetically() { return isEnabled(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY); } /** * Accessor for checking whether configuration indicates that * "root wrapping" (use of an extra property/name pair at root level) * is expected or not. */ public abstract boolean useRootWrapping(); /* /********************************************************** /* Configuration: factory methods /********************************************************** */ /** * Method for constructing a specialized textual object that can typically * be serialized faster than basic {@link java.lang.String} (depending * on escaping needed if any, char-to-byte encoding if needed). * * @param src Text to represent * * @return Optimized text object constructed * * @since 2.4 */ public SerializableString compileString(String src) { /* 20-Jan-2014, tatu: For now we will just construct it directly, but * for 2.4 need to allow overriding to support non-standard extensions * to be used by extensions like Afterburner. */ return new SerializedString(src); } /* /********************************************************** /* Configuration: introspectors, mix-ins /********************************************************** */ public ClassIntrospector getClassIntrospector() { return _base.getClassIntrospector(); } /** * Method for getting

JacksonDatabind, 30

<FILEB>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<CHANGES>
if (isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS)) {
buf = buf.forceUseOfBigDecimal(true);
}
<CHANGEE>
<FILEE>
<FILEB>
<CHANGES>
protected boolean _forceBigDecimal;
<CHANGEE>
<CHANGES>
_forceBigDecimal = (ctxt == null)? false
: ctxt.isEnabled(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS);
<CHANGEE>
<CHANGES>
public TokenBuffer forceUseOfBigDecimal(boolean b) {
_forceBigDecimal = b;
return this;
}
<CHANGEE>
<CHANGES>
if (_forceBigDecimal) {
<CHANGEE>
<CHANGES>
writeNumber(p.getDecimalValue());
} else {
<CHANGEE>
<CHANGES>
}
<CHANGEE>
<FILEE>
<FILEB> * into intermediate representation will retain encapsulation of things like * raw value ({@link com.fasterxml.jackson.databind.util.RawValue}) or basic * node identity ({@link JsonNode}). If so, result is a valid tree, but values * are not re-constructed through actual JSON representation. So if transformation * requires actual materialization of JSON (or other data format that this mapper * produces), it will be necessary to do actual serialization. * * @param <T> Actual node type; usually either basic {@link JsonNode} or * {@link com.fasterxml.jackson.databind.node.ObjectNode} * @param fromValue Bean value to convert * @return Root node of the resulting JSON tree */ @SuppressWarnings({ "unchecked", "resource" }) public <T extends JsonNode> T valueToTree(Object fromValue) throws IllegalArgumentException { if (fromValue == null) return null; TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> JsonNode result; try { writeValue(buf, fromValue); JsonParser jp = buf.asParser(); result = readTree(jp); jp.close(); } catch (IOException e) { // should not occur, no real i/o... throw new IllegalArgumentException(e.getMessage(), e); } return (T) result; } /* */ @SuppressWarnings("resource") protected Object _convert(Object fromValue, JavaType toValueType) throws IllegalArgumentException { // also, as per [Issue-11], consider case for simple cast /* But with caveats: one is that while everything is Object.class, we don't * want to "optimize" that out; and the other is that we also do not want * to lose conversions of generic types. */ Class<?> targetType = toValueType.getRawClass(); if (targetType != Object.class && !toValueType.hasGenericTypes() && targetType.isAssignableFrom(fromValue.getClass())) { return fromValue; } // Then use TokenBuffer, which is a JsonGenerator: TokenBuffer buf = new TokenBuffer(this, false); <CHANGES> <CHANGEE> try { // inlined 'writeValue' with minor changes: // first: disable wrapping when writing SerializationConfig config = getSerializationConfig().<SCANS>, tatu: May have a content converter: ser = findConvertingContentSerializer(provider, property, ser); if (ser == null) { // 30-Sep-2012, tatu: One more thing -- if explicit content type is annotated, // we can consider it a static case as well. if (_elementType != null) { // 20-Aug-2013, tatu: Need to avoid trying to access serializer for java.lang.Object tho if ((_staticTyping && _elementType.getRawClass() != Object.class) || hasContentTypeAnnotation(provider, property)) { ser = provider.findValueSerializer(_elementType, property); } } } else { ser = provider.handleSecondaryContextualization(ser, property); } if ((ser != _elementSerializer) || (property != _property) || (_valueTypeSerializer != typeSer) || (_unwrapSingle != unwrapSingle)) { return withResolved(property, typeSer, ser, unwrapSingle); } return this; } /* /********************************************************** /* Accessors /********************************************************** */ @Override public JavaType getContentType() { return _elementType; } @Override public JsonSerializer<?> getContentSerializer() { return _elementSerializer; } /* /********************************************************** /* Serialization /********************************************************** */ // NOTE: as of 2.5, sub-classes SHOULD override (in 2.4 and before, was final), // at least if they can provide access to actual size of value and use `writeStartArray()` // variant that passes size of array to output, which is helpful with some data formats @Override public void serialize(T value, JsonGenerator gen, SerializerProvider provider) throws IOException { if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) && hasSingleElement(value)) { serializeContents(value, gen, provider); return; } gen.writeStartArray(); // [databind#631]: Assign current value, to be accessible by custom serializers gen.setCurrentValue(value); serializeContents(value, gen, provider); gen.writeEndArray(); } @Override public void serializeWithType(T value, Json